I want to be able to use the hint operator from mongodb in Strongloop Loopback. I've been able to use this operator directly from mongodb but I haven't been able to use it from Strongloop Loopback. How can i use it in there?
Thanks in advance
You cannot use $hint
operator directly in strongloop. However there is an alternate way to use it in strongloop.
Suppose your mongodb datasource in loopback name is mongodb
.
//Here app is the loopback app object.
var mongoDb = app.dataSources.mongodb;
var mongoConnector = app.dataSources.mongodb.connector;
var promise = mongoConnector.collection("COLLECTION NAME").find( { $query: {}, $hint: { age : 1 } } )
promise.then(function(value){
//Process data..
})
.catch(function(err){
//Error..
});