Forked from mikermcneil/waterline.sails.mongo.native.example.js
Last active
November 26, 2015 08:15
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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); | |
}); | |
}); | |
} | |
}; |
Author
tojibon
commented
Nov 26, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment