Referring to session-based data in a Mongoose virtual attribute

I have a Mongoose model that holds Places. Each place has a lat/lng. I can define a Mongoose virtual attribute called distance that would be used to sort Places in ascending order. What's the best way to refer to the user's location information (let's assume it's stored in a session variable for now) from inside the distance virtual attribute?

For anything involving external data, adding a method to the schema would be a better choice than a virtual property.

I'm solving a similar issue. The problem is that methods are fine if you want perform an operation on a single value but I'm retrieving a list and want to inject a new virtual field into every record in the list - but use session data to generate the field. to do this safely (avoiding globals), I think I'll need to use a QueryStream and inject the new field using an ArrayFormatter that takes the session variables as constructor parameters.

This also looks like a job for LINQ so another approach might be to use one of the ports of LINQ to JS.

If you sill prefer to use virtuals, you can store user location info in NodeJs globals. For example this code may be set after user login:

global.user_location = user.location;