stargate / data-api

JSON document API for Apache Cassandra (formerly known as JSON API)
https://stargate.io
Apache License 2.0
14 stars 16 forks source link

SPEC - complete spec on the projection clause #128

Open amorton opened 1 year ago

amorton commented 1 year ago

work in progress is https://github.com/stargate/jsonapi/blob/main/docs/jsonapi-spec.textile#clauseProjection

Projection is an ordered dictionary, supports dot notation for fields paths and nested form {{{ field: { nestedfield: } }}}

Probably want to continue to exclude the $ array projection operation as this involves applying filtering logic to arrays in memory , and is not needed for demos as far as we know.

Work out if we need code and postman updates

vkarpov15 commented 1 year ago

Projection support came up in https://github.com/stargate/stargate-mongoose/pull/17 . It looks like Mongoose makes use of projections with save() when there's no changes to save. The projection that save() uses is very simple, just { _id: 1 } (exclude everything other than _id). But I think rudimentary support for projections is now more important for the demo. We currently strip out this projection in the stargate-mongoose driver, but I'd rather not have to do that for the demo.

Also worth mentioning: Mongoose expects projection to be an option to findOne() and find(). I'm not sure how closely you want to map the driver API that Mongoose expects, projection as a top-level clause rather than as a property of options is not hard to work around.

amorton commented 1 year ago

I'm not sure how closely you want to map the driver API that Mongoose expects, projection as a top-level clause rather than as a property of options is not hard to work around.

It was a decision to consistently handle projection, sort, filter, and update as top level clauses rather than sometimes on the options. The stargate driver should make this invisible to mongoose.

sync-by-unito[bot] commented 1 year ago

➤ Mahesh Rajamani commented:

Tatu Saloranta would be help on this change.