MCPcopy Create free account
hub / github.com/documentdb/documentdb / bson_dollar_nin

Function bson_dollar_nin

pg_documentdb/src/query/bson_dollar_operators.c:1601–1625  ·  view source on GitHub ↗

* bson_dollar_nin implements the $nin functionality * in the runtime. This traverses the document based on * filter dot-notation syntax and for all possible values, checks * that at least one does not match the query value presented. * Note: per $nin requirements, documents that don't have the field * are also considered to be $nin. */

Source from the content-addressed store, hash-verified

1599 * are also considered to be $nin.
1600 */
1601Datum
1602bson_dollar_nin(PG_FUNCTION_ARGS)
1603{
1604 pgbson *document = PG_GETARG_PGBSON(0);
1605 bson_iter_t documentIterator;
1606 TraverseInValidateState state = { 0 };
1607
1608 pgbsonelement filterElement = { 0 };
1609 PopulateDollarInValidationState(fcinfo, &state, &filterElement, false);
1610
1611 PgbsonInitIterator(document, &documentIterator);
1612
1613 TraverseBson(&documentIterator, filterElement.path, &state.traverseState,
1614 &CompareExecutionFuncs);
1615
1616 if (state.hasNull)
1617 {
1618 /* If any element in the input is null and the target path cannot be found in the document, we'll not choose that document. */
1619 PG_RETURN_BOOL(state.traverseState.compareResult == CompareResult_Mismatch);
1620 }
1621 else
1622 {
1623 PG_RETURN_BOOL(state.traverseState.compareResult != CompareResult_Match);
1624 }
1625}
1626
1627
1628/*

Callers

nothing calls this directly

Calls 3

PgbsonInitIteratorFunction · 0.85
TraverseBsonFunction · 0.85

Tested by

no test coverage detected