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

Function PgbsonGetDocumentId

pg_documentdb_core/src/io/pgbson.c:1888–1899  ·  view source on GitHub ↗

* PgbsonGetDocumentId returns the _id of a BSON document in projected form * as a bytea. */

Source from the content-addressed store, hash-verified

1886 * as a bytea.
1887 */
1888pgbson *
1889PgbsonGetDocumentId(const pgbson *document)
1890{
1891 bson_iter_t iterator;
1892 if (!PgbsonInitIteratorAtPath(document, "_id", &iterator))
1893 {
1894 ereport(ERROR, (errmsg("unexpected: document does not have an _id")));
1895 }
1896
1897 const bson_value_t *objectIdValue = bson_iter_value(&iterator);
1898 return BsonValueToDocumentPgbson(objectIdValue);
1899}
1900
1901
1902/*

Callers 5

command_insert_workerFunction · 0.85
PreprocessInsertionDocFunction · 0.85
UpdateOneFunction · 0.85
UpdateOneInternalFunction · 0.85
UpsertDocumentFunction · 0.85

Calls 2

PgbsonInitIteratorAtPathFunction · 0.85

Tested by

no test coverage detected