-
Notifications
You must be signed in to change notification settings - Fork 603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Projections #1310
Projections #1310
Conversation
attributes = [attributes]; | ||
} | ||
|
||
this._criteria.select = attributes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should append to existing select and not replace it. Will allow to call select twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah good call!
For the populates, especially joins - WL-schema also needs to honour the select arrays. FYI. :-) |
hello , now i can use .selet() and .populate('',{select: []}) ? |
+1 |
👍 @particlebanana looks great man. To get reaaallllll specific for a second, what happens if I:
My thoughts are:
|
@mikermcneil started building out tests for projections in the adapter test suite and added the following checks. balderdashy/waterline-adapter-tests#106
Returns all fields for the record. Same as
Gets normalized into
Gets normalized into
Only returns the primary key for the record. |
Is this actually removing the unnecessary fields on waterline itself by modifying the returned data or is this doing projection queries on the db side (i.e mongo)? |
@Salakar this supports adapter level projections so it's up to the adapter to build them correctly. The latest version of Waterline adds this support and it's implemented in the sql adapters as well as mongo I believe. |
I have an other case: if What do you think? From the code, I see that undefined or false is not handled. https://github.com/balderdashy/waterline/blob/master/lib/waterline/utils/normalize.js#L193 May be it's handled somewhere else? |
I can create a PR for this |
What happened to this feature? Is it supported? It doesn't work on Sails 1.2.3. |
I made some tests. It works currently only with population of one-to-many relationship. I made a pull request to solve the one-to-one relationship issue: |
DO NOT MERGE
This PR represents the initial work for projections on both the parent and child criteria. It finally brings official support for
select
and adds a.select()
method to the deferred object. It also adds support for usingselect
inside of criteria in apopulate
.One thing to note is that any primary keys and foreign keys used in a join will always be selected. This is unavoidable due to the way we currently build up join queries and combine results in cross-adapter populates.
The first thing that needs to happen is tests in Waterline Adapter Tests to ensure things won't break across the officially supported adapters. There is a corresponding PR in Waterline Sequel that needs to be brought in for the SQL adapters and I'm sure there will be some slight tweaks that need to happen in the Mongo adapter.
Example Use: