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

Method call

src/ExtCmd.actor.cpp:178–210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

176struct GetlasterrorCmd {
177 static const char* name;
178 ACTOR static Future<Reference<ExtMsgReply>> call(Reference<ExtConnection> ec,
179 Reference<ExtMsgQuery> query,
180 Reference<ExtMsgReply> reply) {
181 state bson::BSONObjBuilder bob;
182
183 Future<WriteResult> lastWrite = ec->lastWrite;
184
185 bob.appendNumber("connectionId", (long long)ec->connectionId);
186
187 try {
188 WriteResult res = wait(lastWrite);
189 bob.appendNumber("n", (long long)res.n); //< FIXME: ???
190 bob << "err" << BSONNULL << "ok" << 1.0;
191 if (!res.upsertedOIDList.empty()) {
192 bob.appendElements(DataValue::decode_key_part(res.upsertedOIDList[0]).wrap("upserted"));
193 }
194 if (res.type == WriteType::UPDATE) {
195 bob << "updatedExisting" << (res.nModified > 0 && res.upsertedOIDList.empty());
196 }
197 } catch (Error& e) {
198 bob.append("err", e.what());
199 bob.append("code", e.code());
200 bob.appendNumber("n", (long long)0);
201 bob.append("ok", 1.0);
202 }
203
204 reply->addDocument(bob.obj());
205 reply->setResponseFlags(8);
206
207 ec->lastWrite = WriteResult();
208
209 return reply;
210 }
211};
212REGISTER_CMD(GetlasterrorCmd, "getlasterror");
213

Callers

nothing calls this directly

Calls 6

WriteResultClass · 0.85
emptyMethod · 0.80
wrapMethod · 0.80
appendMethod · 0.80
addDocumentMethod · 0.80
setResponseFlagsMethod · 0.80

Tested by

no test coverage detected