diff --git a/package.json b/package.json index 3cddf12..653367b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hibas123/realtimedb", - "version": "2.0.0-beta.5", + "version": "2.0.0-beta.6", "description": "", "main": "lib/index.js", "private": true, diff --git a/src/connection.ts b/src/connection.ts index e747caf..2a188a4 100644 --- a/src/connection.ts +++ b/src/connection.ts @@ -117,7 +117,7 @@ export class ConnectionManager { if (!handler) throw new Error("Invalid Request!"); - let query = db.getQuery(path || [], session.id, isDoc ? "document" : "collection"); + let query = db.getQuery(path || [], session, isDoc ? "document" : "collection"); let res = await handler({ id, data, diff --git a/src/database/database.ts b/src/database/database.ts index 12b4ee1..5e27087 100644 --- a/src/database/database.ts +++ b/src/database/database.ts @@ -4,6 +4,7 @@ import getLevelDB, { LevelDB, deleteLevelDB } from "../storage"; import DocumentLock from "./lock"; import { DocumentQuery, CollectionQuery, Query } from "./query"; import Logging from "@hibas123/nodelogging"; +import Session from "./session"; export class DatabaseManager { static databases = new Map(); @@ -105,13 +106,13 @@ export class Database { } - getQuery(path: string[], sender: string, type: "document" | "collection" | "any") { + getQuery(path: string[], session: Session, type: "document" | "collection" | "any") { if (type === "document") - return new DocumentQuery(this, path, sender); + return new DocumentQuery(this, path, session); else if (type === "collection") - return new CollectionQuery(this, path, sender); + return new CollectionQuery(this, path, session); else - return new Query(this, path, sender); + return new Query(this, path, session); } async stop() { diff --git a/src/index.ts b/src/index.ts index 23c3bc2..e1aa47d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,9 +5,12 @@ import { DatabaseManager } from "./database/database"; import { createServer } from "http"; import { ConnectionManager } from "./connection"; import { LoggingTypes } from "@hibas123/logging"; +import * as pk from "../package.json"; Logging.logLevel = config.dev ? LoggingTypes.Debug : LoggingTypes.Log; +Logging.log("Starting Database version:", pk.version); + DatabaseManager.init().then(() => { const http = createServer(Web.callback()); ConnectionManager.bind(http);