/** | |
* PetController | |
* | |
* @description :: Server-side logic for managing pets | |
* @help :: See http://links.sailsjs.org/docs/controllers | |
*/ | |
module.exports = { | |
index: function (req,res) { | |
Pet.native(function(err, collection) { | |
if (err) return res.serverError(err); | |
collection.find({}, { | |
name: true | |
}).toArray(function (err, results) { | |
if (err) return res.serverError(err); | |
console.log('->',results); | |
return res.ok(results); | |
}); | |
}); | |
} | |
}; |
This comment has been minimized.
This comment has been minimized.
With this example, how we can populate one model using native ? |
This comment has been minimized.
This comment has been minimized.
Is the function inside "native" run in the mongodb server? I mean, no data is sent to waterline until de callback of "toArray")? |
This comment has been minimized.
This comment has been minimized.
Hi Mike, getDB Method manually added in sails-mongo I need to achieve the below code snippet. I am out of thoughts, can you help me on this. I am unable to get docs. var m = function () {
Activity.native(function (err, collection) {
|
This comment has been minimized.
This comment has been minimized.
How Do I use the native() method with promise ( bluebird) I tried I could not find a way out of this? thanks in advance |
This comment has been minimized.
This comment has been minimized.
@Rafi993 I used this syntax: return new Promise((resolve, reject) => {
Pet.native((err, collection) => {
if (err) reject(err)
else collection.find({}, {
name: true
}).toArray((err, results) => {
if (err) reject(err)
else resolve(results)
});
})
} |
This comment has been minimized.
This comment has been minimized.
@Rafi993 |
This comment has been minimized.
This comment has been minimized.
what are the methods that collection supports? because when I do |
This comment has been minimized.
This comment has been minimized.
what's the meaning of collection.find({}, { |
This comment has been minimized.
This comment has been minimized.
Neither. Collection is the collection instance. If your collection is called pet, then your model is most likely Pet. Then: |
This comment has been minimized.
Its very useful for me..
Thanks Sir......