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

Function BsonValueToPgbsonElement

pg_documentdb_core/src/io/pgbsonelement.c:231–252  ·  view source on GitHub ↗

* For a given bson value of document type, converts to a pgbsonelement, * which contains the path and value at that path. */

Source from the content-addressed store, hash-verified

229 * which contains the path and value at that path.
230 */
231void
232BsonValueToPgbsonElement(const bson_value_t *bsonValue,
233 pgbsonelement *element)
234{
235 bson_iter_t iterator;
236
237 Assert(bsonValue != NULL);
238
239 if (!bson_iter_init_from_data(&iterator,
240 bsonValue->value.v_doc.data,
241 bsonValue->value.v_doc.data_len))
242 {
243 ereport(ERROR, (errcode(ERRCODE_DOCUMENTDB_BADVALUE),
244 errmsg("Could not initialize bson iterator.")));
245 }
246
247 if (!bson_iter_next(&iterator))
248 {
249 ereport(ERROR, errmsg("invalid input BSON: Should not be empty document"));
250 }
251 BsonIterToPgbsonElement(&iterator, element);
252}
253
254
255/*

Calls 1

BsonIterToPgbsonElementFunction · 0.85

Tested by

no test coverage detected