Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tojibon/bfd548a2bd1768deab71 to your computer and use it in GitHub Desktop.
Save tojibon/bfd548a2bd1768deab71 to your computer and use it in GitHub Desktop.
This works in Sails v0.10.0-rc7 (Waterline v0.10.0-rc12)
/**
* PetController
*
* @description :: Server-side logic for managing pets
* @help :: See http://links.sailsjs.org/docs/controllers
*/
module.exports = {
index: function (req,res) {
// Grab an instance of the mongo-driver
Pet.native(function(err, collection) {
if (err) return res.serverError(err);
// Execute any query that works with the mongo js driver
collection.find({}, {
name: true
}).toArray(function (err, results) {
if (err) return res.serverError(err);
console.log('->',results);
return res.ok(results);
});
});
}
};
@tojibon
Copy link
Author

tojibon commented Nov 26, 2015

       Friend.native(function(err, collection) {
          if (err) return res.serverError(err);

          collection.find({}, {
            friend1: true
          }).toArray(function (err, results) {
            if (err) return res.serverError(err);
              console.log(results);
            next(results);
          });
        });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment