common::Error CommandsApi::Merge(internal::CommandHandler* handler, commands_args_t argv, FastoObject* out) { DBConnection* rocks = static_cast<DBConnection*>(handler); common::Error err = rocks->Merge(argv[0], argv[1]); if (err) { return err; } common::StringValue* val = common::Value::CreateStringValue("OK"); FastoObject* child = new FastoObject(out, val, rocks->GetDelimiter()); out->AddChildren(child); return common::Error(); }
common::Error CommandsApi::Info(internal::CommandHandler* handler, commands_args_t argv, FastoObject* out) { DBConnection* mdb = static_cast<DBConnection*>(handler); ServerInfo::Stats statsout; common::Error err = mdb->Info(argv.size() == 1 ? argv[0] : std::string(), &statsout); if (err) { return err; } common::StringValue* val = common::Value::CreateStringValue(ServerInfo(statsout).ToString()); FastoObject* child = new FastoObject(out, val, mdb->GetDelimiter()); out->AddChildren(child); return common::Error(); }
common::Error CommandsApi::DropDatabase(internal::CommandHandler* handler, commands_args_t argv, FastoObject* out) { UNUSED(argv); DBConnection* mdb = static_cast<DBConnection*>(handler); ServerInfo::Stats statsout; common::Error err = mdb->DropDatabase(); if (err) { return err; } common::StringValue* val = common::Value::CreateStringValue("OK"); FastoObject* child = new FastoObject(out, val, mdb->GetDelimiter()); out->AddChildren(child); return common::Error(); }
common::Error CommandsApi::Mget(internal::CommandHandler* handler, commands_args_t argv, FastoObject* out) { DBConnection* rocks = static_cast<DBConnection*>(handler); std::vector<std::string> keysget; for (size_t i = 0; i < argv.size(); ++i) { keysget.push_back(argv[i]); } std::vector<std::string> keysout; common::Error err = rocks->Mget(keysget, &keysout); if (err) { return err; } common::ArrayValue* ar = common::Value::CreateArrayValue(); for (size_t i = 0; i < keysout.size(); ++i) { common::StringValue* val = common::Value::CreateStringValue(keysout[i]); ar->Append(val); } FastoObject* child = new FastoObject(out, ar, rocks->GetDelimiter()); out->AddChildren(child); return common::Error(); }