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
Add .pick()
and .omit()
methods
#952
Conversation
This commit adds a `pick` clause to the criteria object which allows for including only specific model attributes within the query result. It accepts the follwing syntax: `.pick(['attr1', 'attr2'])` `.pick('attr1', 'attr2')` `.pick({attr1: 1, attr2: 1})`
This commit adds a `omit` clause to the criteria object which allows for excluding model attributes from the query result. It accepts the follwing syntax: `.omit(['attr1', 'attr2'])` `.omit('attr1', 'attr2')` `.omit({attr1: 1, attr2: 1})`
#73 actually asks for a
Any volunteers for this? |
re: http://stackoverflow.com/a/29769995/291180 @dmarcelino would you mind adding a quick sentence or two in the docs about how the |
@tjwebb, I can't believe you didn't know about it... to be honest I don't remember how I found out it existed. Sure, I'll look into adding it. |
Yea I sort of knew about it, but I've never used it and didn't really know the API. Is it unit tested? |
I don't think it is, there are some tests that use it (quick search) but no particular unit test to explicitly test it. |
Why isn't this a feature yet? |
Any news on this? |
closed w/o comment? |
personally i think that this should be structured just like mongo structures it... if your going to use "select" or "pick"... not omit it should just be { field: 0 || 1 }, where 0 is to omit, and 1 is to include. by default if no selection is made everything is included. by default if a field is marked with 1 ID is still included unless explicitly marked 0. |
This PR is the same as #509, but targeting
0.11
, props to @jasonsims. Please check #509 for the full discussion.Original message:
cc: @clarkorz, @mikermcneil, @mdunisch, @particlebanana, @sskyy, @devinivy, @tjwebb