UNPKG

falkordb

Version:
120 lines (119 loc) 4.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Single = void 0; class Single { client; #usePool; constructor(client) { this.client = client; this.#usePool = !!this.client.options?.isolationPoolOptions; } init(_falkordb) { return Promise.resolve(); } async query(graph, query, options, compact = true) { const reply = this.#usePool ? await this.client.executeIsolated(async (isolatedClient) => { return isolatedClient.falkordb.query(graph, query, options, compact); }) : await this.client.falkordb.query(graph, query, options, compact); return reply; } async roQuery(graph, query, options, compact = true) { const reply = this.#usePool ? await this.client.executeIsolated(async (isolatedClient) => { return isolatedClient.falkordb.roQuery(graph, query, options, compact); }) : await this.client.falkordb.roQuery(graph, query, options, compact); return reply; } async delete(graph) { if (this.#usePool) { return this.client.executeIsolated(async (isolatedClient) => { const reply = isolatedClient.falkordb.delete(graph); return reply.then(() => { }); }); } const reply = this.client.falkordb.delete(graph); return reply.then(() => { }); } async explain(graph, query) { if (this.#usePool) { return this.client.executeIsolated(async (isolatedClient) => { return isolatedClient.falkordb.explain(graph, query); }); } return this.client.falkordb.explain(graph, query); } async profile(graph, query) { if (this.#usePool) { return this.client.executeIsolated(async (isolatedClient) => { return isolatedClient.falkordb.profile(graph, query); }); } return this.client.falkordb.profile(graph, query); } async list() { return this.client.falkordb.list(); } async configGet(configKey) { return this.client.falkordb.configGet(configKey); } async configSet(configKey, value) { const reply = this.client.falkordb.configSet(configKey, value); return reply.then(() => { }); } async info(section) { return this.client.falkordb.info(section); } async slowLog(graph) { if (this.#usePool) { return this.client.executeIsolated(async (isolatedClient) => { return isolatedClient.falkordb.slowLog(graph); }); } return this.client.falkordb.slowLog(graph); } async memoryUsage(graph, options) { if (this.#usePool) { return this.client.executeIsolated(async (isolatedClient) => { return isolatedClient.falkordb.memoryUsage(graph, options); }); } return this.client.falkordb.memoryUsage(graph, options); } async constraintCreate(graph, constraintType, entityType, label, ...properties) { const reply = this.client.falkordb.constraintCreate(graph, constraintType, entityType, label, ...properties); return reply.then(() => { }); } async constraintDrop(graph, constraintType, entityType, label, ...properties) { const reply = this.client.falkordb.constraintDrop(graph, constraintType, entityType, label, ...properties); return reply.then(() => { }); } async udfLoad(name, script, replace = false) { return this.client.falkordb.udfLoad(name, script, replace); } async udfList(lib, withCode = false) { return this.client.falkordb.udfList(lib, withCode); } async udfFlush() { return this.client.falkordb.udfFlush(); } async udfDelete(lib) { return this.client.falkordb.udfDelete(lib); } async copy(srcGraph, destGraph) { return this.client.falkordb.copy(srcGraph, destGraph); } quit() { return this.disconnect(); } async disconnect() { const reply = this.client.disconnect(); return reply.then(() => { }); } async getConnection() { return this.client; } } exports.Single = Single;