* PgbsonGetDocumentId returns the _id of a BSON document in projected form * as a bytea. */
| 1886 | * as a bytea. |
| 1887 | */ |
| 1888 | pgbson * |
| 1889 | PgbsonGetDocumentId(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 | /* |
no test coverage detected