* Traverses the document for a given dot-path notation * When a matching path is found, then returns true if the * element is an array with the specified size. Returns false * otherwise. */
| 619 | * otherwise. |
| 620 | */ |
| 621 | Datum |
| 622 | bson_dollar_size(PG_FUNCTION_ARGS) |
| 623 | { |
| 624 | pgbson *document = PG_GETARG_PGBSON(0); |
| 625 | pgbson *filter = PG_GETARG_PGBSON(1); |
| 626 | |
| 627 | bson_iter_t documentIterator; |
| 628 | pgbsonelement filterElement; |
| 629 | TraverseElementValidateState state = { 0 }; |
| 630 | PgbsonInitIterator(document, &documentIterator); |
| 631 | PgbsonToSinglePgbsonElement(filter, &filterElement); |
| 632 | filterElement.pathLength = 0; |
| 633 | state.filter = &filterElement; |
| 634 | state.traverseState.matchFunc = CompareArraySizeMatch; |
| 635 | TraverseBson(&documentIterator, filterElement.path, &state.traverseState, |
| 636 | &CompareTopLevelFieldExecutionFuncs); |
| 637 | PG_RETURN_BOOL(state.traverseState.compareResult == CompareResult_Match); |
| 638 | } |
| 639 | |
| 640 | |
| 641 | /* |
nothing calls this directly
no test coverage detected