lightblue-platform / lightblue-docs-specs

All specifications for lightblue.
GNU General Public License v3.0
1 stars 10 forks source link

How does `"include": false` with / without inner projections interact with array projections? #24

Closed alechenninger closed 8 years ago

alechenninger commented 9 years ago

Docs aren't very complete WRT projections, and I'm trying to flush out https://github.com/alechenninger/lightblue.js/issues/12

Specifically, what is the behavior of the following examples:

  1. An excluded array field with a projection that includes a field. Is the entire array excluded? Is only the street address in the array excluded? Is only the street address in the array included? Are only street addresses in Raleigh excluded?
[ 
  {"field": "*", include: true},
  {"field": "address", "include": false,
   "match": { "field": "city", "op": "=", "rvalue": "City" },
   "project": { "field": "streetaddress": "include": true}}
]

2. An excluded array field with a projection that excluded a field. Same questions as first example.

[ 
  {"field": "*", include: true},
  {"field": "address", "include": false,
   "match": { "field": "city", "op": "=", "rvalue": "City" }, 
   "project": { "field": "streetaddress": "include": false}}
]

Thanks!

bserdar commented 9 years ago

This is how projections work: for every field in the document, we first determine if the field matches projection criteria. For { field:"*" }, all fields match. For { field: "array", match: Q }, those fields for which Q holds matches. Once a field matches, the decision to include or exclude the matching fields is determined by the value of 'include'. In an array of projection rules, whether or not to include a field is determined by the last matching rule.

So, in the first example: first rule matches everything. Second rule only matched address elements whose city is Raleigh. So, second rule will decide to exclude the elements with city:Raleigh, and the first rule will include everything, and you'll end up with a document containing everything except addresses whose city is Raleigh. Projection is meaningless, because this is an exclusion, not an inclusion.

Same result for the second example.

On Fri, Aug 14, 2015 at 7:39 PM, Alec Henninger notifications@github.com wrote:

Docs aren't very complete WRT projections, and I'm trying to flush out alechenninger/lightblue.js#12 https://github.com/alechenninger/lightblue.js/issues/12

Specifically, what is the behavior of the following examples:

  1. An excluded array field with a projection that includes a field. Is the entire array excluded? Is only the street address in the array excluded? Is only the street address in the array included?

[ {"field": "*", include: true}, {"field": "address", "include": false, "match": { "city": "Raleigh" }, "project": { "field": "streetaddress": "include": true}} ]

  1. An excluded array field with a projection that excluded a field. Is the entire array excluded? Is only the street address in the array excluded? Is only the street address in the array included?

[ {"field": "*", include: true}, {"field": "address", "include": false, "match": { "city": "Raleigh" }, "project": { "field": "streetaddress": "include": false}} ]

Thanks!

— Reply to this email directly or view it on GitHub https://github.com/lightblue-platform/lightblue-docs-specs/issues/24.

alechenninger commented 8 years ago

This makes sense. Thanks!