| 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); |
nothing calls this directly
no test coverage detected