-1

How to execute mongo db custom functions from sails.js app? I could not find any suitable way to execute custom functions. I am able to access only collections from the sails app, using the predefined functions provided in the waterline ORM.

1 Answers1

0

You can access MongoDB's native methods by invoking sails .native() method:

Below is an example from Sails' documentation

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);
    return res.ok(results);
  });
});
  • .find is not a custom function of mongo db. i want to access custom mongo functions, which are stored into system.js in mongo. – Sourav Rakshit May 02 '16 at 05:45