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
80 lines • 2.61 kB
JavaScript
"use strict";
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());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const command_types_1 = require("../tcp/types/command.types");
/**
* Reader Proxy - Query builder for remote queries
* Mirrors the Reader class API (chainable query builder)
*/
class ReaderProxy {
constructor(client, dbName, collectionName, query) {
this.findOneValue = false;
this.client = client;
this.dbName = dbName;
this.collectionName = collectionName;
this.queryFilter = query;
}
/**
* Set limit for query results
*/
Limit(limit) {
this.limitValue = limit;
return this;
}
/**
* Set skip for pagination
*/
Skip(skip) {
this.skipValue = skip;
return this;
}
/**
* Set sort order
*/
Sort(sort) {
this.sortValue = sort;
return this;
}
/**
* Set findOne flag to return single document
*/
findOne(value) {
this.findOneValue = value;
return this;
}
/**
* Execute the query
*/
exec() {
return __awaiter(this, void 0, void 0, function* () {
const params = {
dbName: this.dbName,
collectionName: this.collectionName,
query: this.queryFilter,
};
if (this.limitValue !== undefined) {
params.limit = this.limitValue;
}
if (this.skipValue !== undefined) {
params.skip = this.skipValue;
}
if (this.sortValue) {
params.sort = this.sortValue;
}
if (this.findOneValue) {
params.findOne = this.findOneValue;
}
return yield this.client.sendCommand(command_types_1.CommandType.QUERY_DOCUMENTS, params);
});
}
}
exports.default = ReaderProxy;
//# sourceMappingURL=ReaderProxy.js.map