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

Function BuildResponseMessage

pg_documentdb/src/commands/delete.c:1866–1896  ·  view source on GitHub ↗

* BuildResponseMessage builds the response BSON for a delete command. */

Source from the content-addressed store, hash-verified

1864 * BuildResponseMessage builds the response BSON for a delete command.
1865 */
1866static pgbson *
1867BuildResponseMessage(BatchDeletionResult *batchResult)
1868{
1869 pgbson_writer resultWriter;
1870 PgbsonWriterInit(&resultWriter);
1871 PgbsonWriterAppendInt32(&resultWriter, "n", 1, batchResult->rowsDeleted);
1872 PgbsonWriterAppendDouble(&resultWriter, "ok", 2, batchResult->ok);
1873
1874 if (batchResult->writeErrors != NIL)
1875 {
1876 pgbson_array_writer writeErrorsArrayWriter;
1877 PgbsonWriterStartArray(&resultWriter, "writeErrors", 11, &writeErrorsArrayWriter);
1878
1879 ListCell *writeErrorCell = NULL;
1880 foreach(writeErrorCell, batchResult->writeErrors)
1881 {
1882 WriteError *writeError = lfirst(writeErrorCell);
1883
1884 pgbson_writer writeErrorWriter;
1885 PgbsonArrayWriterStartDocument(&writeErrorsArrayWriter, &writeErrorWriter);
1886 PgbsonWriterAppendInt32(&writeErrorWriter, "index", 5, writeError->index);
1887 PgbsonWriterAppendInt32(&writeErrorWriter, "code", 4, writeError->code);
1888 PgbsonWriterAppendUtf8(&writeErrorWriter, "errmsg", 6, writeError->errmsg);
1889 PgbsonArrayWriterEndDocument(&writeErrorsArrayWriter, &writeErrorWriter);
1890 }
1891
1892 PgbsonWriterEndArray(&resultWriter, &writeErrorsArrayWriter);
1893 }
1894
1895 return PgbsonWriterGetPgbson(&resultWriter);
1896}

Callers 2

command_deleteFunction · 0.70
command_delete_workerFunction · 0.70

Calls 10

PgbsonWriterInitFunction · 0.85
PgbsonWriterAppendInt32Function · 0.85
PgbsonWriterAppendDoubleFunction · 0.85
PgbsonWriterStartArrayFunction · 0.85
PgbsonWriterAppendUtf8Function · 0.85
PgbsonWriterEndArrayFunction · 0.85
PgbsonWriterGetPgbsonFunction · 0.85
foreachFunction · 0.50

Tested by

no test coverage detected