@joystick.js/db-canary
Version:
JoystickDB - A minimalist database server for the Joystick framework
2 lines (1 loc) • 2.26 kB
JavaScript
const r=(c,t,e={})=>({admin_action:c,database:t,...e}),n=(c,t,e,s={})=>({admin_action:c,database:t,collection:e,...s}),a=async(c,t)=>c.send_request("admin",t);class _{constructor(t,e){this.client=t,this.database_name=e}collection(t){const e=this.client.constructor.Collection;return new e(this.client,this.database_name,t)}async list_collections(){const t=r("list_collections",this.database_name);return a(this.client,t)}async get_stats(){const t=r("get_database_stats",this.database_name);return a(this.client,t)}async drop_database(){const t=r("drop_database",this.database_name);return a(this.client,t)}async create_collection(t,e={}){const s=n("create_collection",this.database_name,t,{options:e});return a(this.client,s)}async list_documents(t){const e=n("list_documents",this.database_name,t);return a(this.client,e)}async get_document(t,e){const s=n("get_document",this.database_name,t,{document_id:e});return a(this.client,s)}async query_documents(t,e){const s=n("query_documents",this.database_name,t,{filter:e});return a(this.client,s)}async insert_document(t,e){const s=n("insert_document",this.database_name,t,{document:e});return a(this.client,s)}async update_document(t,e,s){const i=n("update_document",this.database_name,t,{document_id:e,update:s});return a(this.client,i)}async delete_document(t,e){const s=n("delete_document",this.database_name,t,{document_id:e});return a(this.client,s)}async stats(){return this.client.send_request("admin",{admin_action:"stats"})}async ping(){return this.client.send_request("ping",{},!1)}async backup_now(){return this.client.backup_now()}async list_backups(){return this.client.list_backups()}async restore_backup(t){return this.client.restore_backup(t)}async get_replication_status(){return this.client.get_replication_status()}async add_secondary(t){return this.client.add_secondary(t)}async remove_secondary(t){return this.client.remove_secondary(t)}async sync_secondaries(){return this.client.sync_secondaries()}async get_secondary_health(){return this.client.get_secondary_health()}async get_forwarder_status(){return this.client.get_forwarder_status()}async get_auto_index_stats(){return this.client.get_auto_index_stats()}async reload(){return this.client.reload()}}var d=_;export{d as default};