MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / queryAsync

Method queryAsync

Source/Basic/Database.cpp:296–318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

294}
295
296void DB::queryAsync(String sql, std::vector<Own<Value>>&& args, bool withColumns, const std::function<void(std::optional<Rows>&)>& callback) {
297 std::string sqlStr(sql.toString());
298 auto argsPtr = std::make_shared<std::vector<Own<Value>>>(std::move(args));
299 _thread->run(
300 [sqlStr, argsPtr = std::move(argsPtr), withColumns, db = _database.get()]() {
301 try {
302 auto result = SharedDB.queryUnsafe(db, sqlStr, *argsPtr, withColumns);
303 return Values::alloc(std::move(result));
304 } catch (std::exception& e) {
305 Warn("failed to execute DB query: {}", e.what());
306 return Own<Values>{};
307 }
308 },
309 [callback](Own<Values> values) {
310 std::optional<Rows> opt;
311 if (values) {
312 Rows result;
313 values->get(result);
314 opt = std::move(result);
315 }
316 callback(opt);
317 });
318}
319
320void DB::insertAsync(String tableName, std::deque<std::vector<Own<Value>>>&& rows, const std::function<void(bool)>& callback) {
321 std::string tableStr(tableName.toString());

Callers

nothing calls this directly

Calls 8

moveFunction · 0.85
queryUnsafeMethod · 0.80
toStringMethod · 0.65
runMethod · 0.65
getMethod · 0.65
allocFunction · 0.50
WarnFunction · 0.50
whatMethod · 0.45

Tested by

no test coverage detected