MCPcopy Create free account
hub / github.com/FoundationDB/fdb-document-layer / upsertActor

Method upsertActor

src/ExtMsg.actor.cpp:1401–1416  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1399 ExtOperatorUpsert(bson::BSONObj selector, bson::BSONObj update) : selector(selector), update(update) {}
1400
1401 ACTOR static Future<Reference<IReadWriteContext>> upsertActor(ExtOperatorUpsert* self,
1402 Reference<CollectionContext> cx) {
1403 Optional<IdInfo> encodedIds = extractEncodedIds(self->selector);
1404 if (!encodedIds.present())
1405 encodedIds = extractEncodedIdsFromUpdate(self->update);
1406 int selectorOperators = hasOperatorFieldnames(self->selector, -1, 0);
1407 bson::BSONObj thingToInsert;
1408 if (!selectorOperators) {
1409 thingToInsert = self->selector;
1410 } else {
1411 thingToInsert = transformOperatorQueryToUpdatableDocument(self->selector);
1412 }
1413 state Reference<IReadWriteContext> dcx = wait(insertDocument(cx, thingToInsert, encodedIds));
1414 wait(updateDocument(dcx, self->update, true, dcx->getKeyEncodedId()));
1415 return dcx;
1416 }
1417
1418 Future<Reference<IReadWriteContext>> insert(Reference<CollectionContext> cx) override {
1419 return upsertActor(this, cx);

Callers

nothing calls this directly

Calls 5

extractEncodedIdsFunction · 0.85
hasOperatorFieldnamesFunction · 0.85
getKeyEncodedIdMethod · 0.45

Tested by

no test coverage detected