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

Class ExtSimpleUpsert

src/ExtMsg.actor.cpp:1425–1443  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1423};
1424
1425struct ExtSimpleUpsert : ConcreteInsertOp<ExtSimpleUpsert> {
1426 bson::BSONObj selector;
1427 bson::BSONObj update;
1428
1429 ExtSimpleUpsert(bson::BSONObj selector, bson::BSONObj update) : selector(selector), update(update) {}
1430
1431 std::string describe() override { return "SimpleUpsert(" + selector.toString() + "," + update.toString() + ")"; }
1432
1433 Future<Reference<IReadWriteContext>> insert(Reference<CollectionContext> cx) override {
1434 Optional<IdInfo> encodedIds = extractEncodedIds(selector);
1435 Optional<IdInfo> updateIds = extractEncodedIds(update);
1436 if (!encodedIds.present()) {
1437 encodedIds = updateIds;
1438 } else if (updateIds.present() && updateIds.get().keyEncoded != encodedIds.get().keyEncoded) {
1439 throw cant_modify_id();
1440 }
1441 return insertDocument(cx, update, encodedIds);
1442 }
1443};
1444
1445Reference<IUpdateOp> operatorUpdate(bson::BSONObj const& msgUpdate) {
1446 return ref(new ExtOperatorUpdate(msgUpdate));

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected