balderdashy / sails

Realtime MVC Framework for Node.js
https://sailsjs.com
MIT License
22.84k stars 1.95k forks source link

Implement join for sails-mongo #7046

Open LouAdrien opened 4 years ago

LouAdrien commented 4 years ago

Node version: Sails version (sails): 1.2.3 ORM hook version (sails-hook-orm): Sockets hook version (sails-hook-sockets): Organics hook version (sails-hook-organics): Grunt hook version (sails-hook-grunt): Uploads hook version (sails-hook-uploads): DB adapter & version (e.g. sails-mysql@5.55.5): Skipper adapter & version (e.g. skipper-s3@5.55.5): "sails-mongo": "^1.0.1",


Using a criteria when populating association raise the warning below. Mongobd does support native join ($lookup). Would it be possible to use it to implement the missing feature?

Warning: Attempting to populatetutorialswith the specified subcriteria, but this MAY NOT BE SAFE, depending on the number of records stored in your models. Since this association does not support optimized populates (i.e. it spans multiple datastores, or uses an adapter that does not support native joins), it is not a good idea to populate it along with a subcriteria that useslimit,skip, and/orsort`-- at least not in a production environment.

This is because, to satisfy the specified limit/skip/sort, many additional records may need to be fetched along the way -- perhaps enough of them to overflow RAM on your server.

If you are just using sails-disk during development, or are certain this is not a problem based on your application's requirements, then you can safely ignore this message. But otherwise, to overcome this, either (A) remove or change this subcriteria and approach this query a different way (such as multiple separate queries or a native query), or (B) configure all involved models to use the same datastore, and/or switch to an adapter like sails-mysql or sails-postgresql that supports native joins. [?] See https://sailsjs.com/support for help.`

sailsbot commented 4 years ago

@LouAdrien Thanks for posting! We'll take a look as soon as possible.

In the mean time, there are a few ways you can help speed things along:

Please remember: never post in a public forum if you believe you've found a genuine security vulnerability. Instead, disclose it responsibly.

For help with questions about Sails, click here.

eashaw commented 4 years ago

Hi @LouAdrien, unfortunately our team doesn’t have the availability to implement this feature right now, but if you have time to make a PR for this we’d be willing to take a look!