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

Function BsonDocumentValueCountKeys

pg_documentdb_core/src/io/pgbson.c:90–107  ·  view source on GitHub ↗

* BsonDocumentValueCountKeys returns the number of keys in a given bson document value. * "value" should be of type BSON_TYPE_ARRAY or BSON_TYPE_DOCUMENT */

Source from the content-addressed store, hash-verified

88 * "value" should be of type BSON_TYPE_ARRAY or BSON_TYPE_DOCUMENT
89 */
90int
91BsonDocumentValueCountKeys(const bson_value_t *value)
92{
93 if (value->value_type != BSON_TYPE_ARRAY && value->value_type != BSON_TYPE_DOCUMENT)
94 {
95 ereport(ERROR, (errcode(ERRCODE_DOCUMENTDB_BADVALUE),
96 errmsg("Value must be either an array type or a document type")));
97 }
98 bson_t bson;
99 if (!bson_init_static(&bson, value->value.v_doc.data,
100 value->value.v_doc.data_len))
101 {
102 ereport(ERROR, (errcode(ERRCODE_DOCUMENTDB_BADVALUE),
103 errmsg("invalid input syntax for BSON")));
104 }
105
106 return bson_count_keys(&bson);
107}
108
109
110/*

Calls

no outgoing calls

Tested by

no test coverage detected