Alessandro Alessandro - 1 year ago 89
Node.js Question

Mongoose find() with function

I want to find an object in my collection which satisfies the following:
getDistance(userDefinedPosition, positionFromDocument) == true.

So I would like to do something like this

Users.find( getDistance(userDefinedPosition, positionFromDocument) == true, function( ... ) )

So userDefinedPosition is value while positionFromDocument is a field from inside a possible match.

Answer Source

Try the following:

Users.$where(getDistance(userDefinedPosition, this.positionFromDocument)).exec(function( ... ))


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download