Skip to content
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

Selective field results #17

Open
mingard opened this issue Jan 19, 2017 · 2 comments
Open

Selective field results #17

mingard opened this issue Jan 19, 2017 · 2 comments
Labels

Comments

@mingard
Copy link

mingard commented Jan 19, 2017

To retrieve only the fields you need, it could be useful to extend the .select() method to limit the returned fields. Something like:

.select({'name': 1, 'age': 1}).from({$p: Person})

also accepting arrays:

.select(['name', 'age']).from({$p: Person})
@anywhichway
Copy link
Owner

@mingard projections are already supported, e.g. db.select({name: {$e1: "name"}}).from({$e1: Object})

Granted the documentation in README.md only provides the signature and not an example, i.e. A <projection> takes the form {<propertyName: {<classVariable: "<objectProperty>"}[, ...]}.

Close this issue if it addresses your needs.

@mingard
Copy link
Author

mingard commented Jan 20, 2017

@anywhichway I suppose I was looking for some syntactic sugar, so rather than:

db.select({name: {$e1: "name"}, age: {$e1: "age"}}).from({$e1: Object})

something like:

db.select({$e1: ["name", "age"]}).from({$e1: Object})

perhaps even the ability to recognise that the request targets a single Object so:

// Multiple 
db.select({$e1: ["name", "age"], $e2: ["name":]}).from({$e1: Object, $e2: Object})
// Single
db.select(["name", "age"]).from({$e1: Object})

Perhaps there's room here for a reasondb-wrapper that takes care of query building?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants