Find mongodb (in mongoose+node.JS) records based on a condition Find mongodb (in mongoose+node.JS) records based on a condition mongoose mongoose

Find mongodb (in mongoose+node.JS) records based on a condition


Your findDistance function needs to be defined in MongoDB, not in node.js, so that it has access to the database fields when it runs. Luckily, MongoDB uses JavaScript for its stored procedures, so the function should work.

See here for instructions on storing and using MongoDB stored procedures.


Its equavilant to stored procedure but not same.And it is recommended to avoid using MongoDB stored function.

For more Info: http://docs.mongodb.org/manual/applications/server-side-javascript/