axiodb
Version:
The Pure JavaScript Alternative to SQLite. Embedded NoSQL database for Node.js with MongoDB-style queries, zero native dependencies, built-in InMemoryCache, and web GUI. Perfect for desktop apps, CLI tools, and embedded systems. No compilation, no platfor
81 lines • 2.96 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const command_types_1 = require("../tcp/types/command.types");
const CollectionProxy_1 = __importDefault(require("./CollectionProxy"));
/**
* Database Proxy - Remote proxy for Database operations
* Mirrors the Database class API
*/
class DatabaseProxy {
constructor(client, dbName) {
this.client = client;
this.dbName = dbName;
}
/**
* Create a collection in the database
*/
createCollection(name, crypto, key) {
return __awaiter(this, void 0, void 0, function* () {
yield this.client.sendCommand(command_types_1.CommandType.CREATE_COLLECTION, {
dbName: this.dbName,
collectionName: name,
crypto,
key,
});
return new CollectionProxy_1.default(this.client, this.dbName, name);
});
}
/**
* Delete a collection from the database
*/
deleteCollection(name) {
return __awaiter(this, void 0, void 0, function* () {
yield this.client.sendCommand(command_types_1.CommandType.DELETE_COLLECTION, {
dbName: this.dbName,
collectionName: name,
});
});
}
/**
* Check if collection exists
*/
isCollectionExists(name) {
return __awaiter(this, void 0, void 0, function* () {
const result = yield this.client.sendCommand(command_types_1.CommandType.COLLECTION_EXISTS, {
dbName: this.dbName,
collectionName: name,
});
return result.exists;
});
}
/**
* Get collection information
*/
getCollectionInfo() {
return __awaiter(this, void 0, void 0, function* () {
return yield this.client.sendCommand(command_types_1.CommandType.GET_COLLECTION_INFO, {
dbName: this.dbName,
});
});
}
/**
* Get database name
*/
get name() {
return this.dbName;
}
}
exports.default = DatabaseProxy;
//# sourceMappingURL=DatabaseProxy.js.map