[SERVER-29585] Create a $_internalSchemaObjectMatch MatchExpression Created: 12/Jun/17  Updated: 30/Oct/23  Resolved: 11/Jul/17

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: 3.5.10

Type: Task Priority: Major - P3
Reporter: Kyle Suarez Assignee: Nicholas Zolnierz
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: Query 2017-07-10, Query 2017-07-31
Participants:

 Description   
Proposed Syntax

{ <path>: $_internalSchemaObjectMatch: {
        <ObjectConstraintMatchExpression>,
        <ObjectConstraintMatchExpression>,
        ...
    }
}

Proposed Semantics

The field at <path> matches the expression if it is an object and matches the sub-expression <topLevelMatchExpression>. $_internalSchemaObjectMatch allows for constraining the properties of a nested object, as top-level match expressions on their own cannot be used to constrain a subobject.



 Comments   
Comment by Githook User [ 11/Jul/17 ]

Author:

{u'username': u'nzolnierzmdb', u'name': u'Nick Zolnierz', u'email': u'nicholas.zolnierz@mongodb.com'}

Message: SERVER-29585: Create a $_internalSchemaObjectMatch MatchExpression
Branch: master
https://github.com/mongodb/mongo/commit/0ebecb306cf68009f01ccde363debfff3b268a9a

Comment by Kyle Suarez [ 27/Jun/17 ]

Reassigning this to Nick, as we're aggressively starting on the JSON Schema-to-MQL translation and require $objectMatch for many recursive object properties.

Comment by David Storch [ 22/Jun/17 ]

A single match expression. You can always use $and or $or to meaningfully join a list of match expressions.

Comment by Kyle Suarez [ 22/Jun/17 ]

Should it accept a single match expression, or a list of match expressions?

Comment by David Storch [ 22/Jun/17 ]

Hmm, these were not my proposed semantics for $_internalSchemaObjectMatch. I was thinking that it would work like $elemMatch. It would accept a path and a nested match expression:

{"path.to.object": {$_internalSchemaObjectMatch: <MatchExpression>}}

It would only match if "path.to.object" contains an element of BSONType::Object which also matches <MatchExpression>. So if you wanted to check that field nestedObj was an object containing at least 5 properties you could write this:

{nestedObj: {$_internalSchemaObjectMatch: {$_internalSchemaMinProperties: 5}}}

Generated at Thu Feb 08 04:21:17 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.