axiodb 10.8.11 โ 11.9.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +447 -315
- package/lib/Services/Auth/AuthEvents.service.d.ts +15 -0
- package/lib/Services/Auth/AuthEvents.service.js +17 -0
- package/lib/Services/Auth/AuthEvents.service.js.map +1 -0
- package/lib/Services/Auth/AuthService.service.js +4 -0
- package/lib/Services/Auth/AuthService.service.js.map +1 -1
- package/lib/Services/Auth/LoginRateLimiter.service.d.ts +35 -0
- package/lib/Services/Auth/LoginRateLimiter.service.js +89 -0
- package/lib/Services/Auth/LoginRateLimiter.service.js.map +1 -0
- package/lib/Services/Collection/collection.operation.d.ts +6 -0
- package/lib/Services/Collection/collection.operation.js +10 -0
- package/lib/Services/Collection/collection.operation.js.map +1 -1
- package/lib/Services/Index/Index.service.d.ts +20 -0
- package/lib/Services/Index/Index.service.js +25 -1
- package/lib/Services/Index/Index.service.js.map +1 -1
- package/lib/Services/Indexation.operation.d.ts +4 -0
- package/lib/Services/Indexation.operation.js +13 -4
- package/lib/Services/Indexation.operation.js.map +1 -1
- package/lib/client/AxioDBCloud.client.d.ts +20 -1
- package/lib/client/AxioDBCloud.client.js +54 -3
- package/lib/client/AxioDBCloud.client.js.map +1 -1
- package/lib/client/CollectionProxy.d.ts +4 -0
- package/lib/client/CollectionProxy.js +11 -0
- package/lib/client/CollectionProxy.js.map +1 -1
- package/lib/client/types/client.types.d.ts +8 -0
- package/lib/client/types/client.types.js.map +1 -1
- package/lib/config/Interfaces/Operation/Indexation.operation.interface.d.ts +2 -0
- package/lib/config/Keys/Permissions.d.ts +13 -0
- package/lib/config/Keys/Permissions.js +21 -1
- package/lib/config/Keys/Permissions.js.map +1 -1
- package/lib/server/config/keys.js +26 -0
- package/lib/server/config/keys.js.map +1 -1
- package/lib/server/controller/Auth/Auth.controller.js +9 -0
- package/lib/server/controller/Auth/Auth.controller.js.map +1 -1
- package/lib/server/controller/Index/Index.controller.d.ts +35 -0
- package/lib/server/controller/Index/Index.controller.js +148 -0
- package/lib/server/controller/Index/Index.controller.js.map +1 -0
- package/lib/server/router/Router.js +6 -0
- package/lib/server/router/Router.js.map +1 -1
- package/lib/server/router/Routers/Index.routes.d.ts +7 -0
- package/lib/server/router/Routers/Index.routes.js +38 -0
- package/lib/server/router/Routers/Index.routes.js.map +1 -0
- package/lib/tcp/config/keys.d.ts +8 -0
- package/lib/tcp/config/keys.js +8 -0
- package/lib/tcp/config/keys.js.map +1 -1
- package/lib/tcp/config/permissions.d.ts +16 -0
- package/lib/tcp/config/permissions.js +46 -0
- package/lib/tcp/config/permissions.js.map +1 -0
- package/lib/tcp/config/protocol.js +13 -0
- package/lib/tcp/config/protocol.js.map +1 -1
- package/lib/tcp/config/server.d.ts +1 -1
- package/lib/tcp/config/server.js +28 -6
- package/lib/tcp/config/server.js.map +1 -1
- package/lib/tcp/connection/ConnectionManager.d.ts +19 -0
- package/lib/tcp/connection/ConnectionManager.js +31 -0
- package/lib/tcp/connection/ConnectionManager.js.map +1 -1
- package/lib/tcp/connection/RequestContext.d.ts +4 -1
- package/lib/tcp/connection/RequestContext.js +4 -1
- package/lib/tcp/connection/RequestContext.js.map +1 -1
- package/lib/tcp/handler/CommandHandler.d.ts +5 -1
- package/lib/tcp/handler/CommandHandler.js +34 -4
- package/lib/tcp/handler/CommandHandler.js.map +1 -1
- package/lib/tcp/handler/handlers/Auth.handler.d.ts +16 -0
- package/lib/tcp/handler/handlers/Auth.handler.js +91 -0
- package/lib/tcp/handler/handlers/Auth.handler.js.map +1 -0
- package/lib/tcp/handler/handlers/Operation.handler.d.ts +4 -0
- package/lib/tcp/handler/handlers/Operation.handler.js +27 -0
- package/lib/tcp/handler/handlers/Operation.handler.js.map +1 -1
- package/lib/tcp/types/command.types.d.ts +2 -0
- package/lib/tcp/types/command.types.js +5 -0
- package/lib/tcp/types/command.types.js.map +1 -1
- package/lib/tcp/types/protocol.types.d.ts +2 -0
- package/lib/tcp/types/protocol.types.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,143 +16,207 @@
|
|
|
16
16
|
[](https://www.typescriptlang.org/)
|
|
17
17
|
[](https://www.npmjs.com/package/axiodb)
|
|
18
18
|
|
|
19
|
-
> **AxioDB** is an embedded NoSQL database for Node.js with MongoDB-style queries. Zero native dependencies, no compilation, no platform issues. Pure JavaScript from npm install to production. Think SQLite, but NoSQL with JavaScript queriesโperfect for desktop apps, CLI tools, and embedded systems.
|
|
20
|
-
|
|
21
19
|
๐ **[Official Documentation](https://axiodb.in/)**: Access full guides, examples, and API references.
|
|
22
20
|
|
|
23
21
|
---
|
|
24
22
|
|
|
25
|
-
##
|
|
23
|
+
## Table of Contents
|
|
24
|
+
|
|
25
|
+
- [What is AxioDB, and why does it exist?](#what-is-axiodb-and-why-does-it-exist)
|
|
26
|
+
- [Installation](#-installation)
|
|
27
|
+
- [Quick Start โ Local AxioDB](#-quick-start--local-axiodb)
|
|
28
|
+
- [Features](#-features)
|
|
29
|
+
- [AxioDBCloud โ Connecting Remotely](#-axiodbcloud--connecting-remotely)
|
|
30
|
+
- [Simple: connect without authentication](#simple-connect-without-authentication)
|
|
31
|
+
- [Advanced: TCP authentication](#advanced-tcp-authentication)
|
|
32
|
+
- [Troubleshooting](#-troubleshooting)
|
|
33
|
+
- [Docker Deployment](#-docker-deployment)
|
|
34
|
+
- [Simple: run the container](#simple-run-the-container)
|
|
35
|
+
- [Advanced: env vars, volumes, Compose](#advanced-env-vars-volumes-compose)
|
|
36
|
+
- [Built-in Web GUI & Authentication (RBAC)](#-built-in-web-gui--authentication-rbac)
|
|
37
|
+
- [Detailed Usage](#-detailed-usage)
|
|
38
|
+
- [API Reference](#-api-reference)
|
|
39
|
+
- [Best Practices](#-best-practices)
|
|
40
|
+
- [Architecture & Internal Mechanisms](#-architecture--internal-mechanisms)
|
|
41
|
+
- [Comparisons](#-comparisons)
|
|
42
|
+
- [Limitations & Honest Positioning](#-limitations--honest-positioning)
|
|
43
|
+
- [FAQ](#-faq)
|
|
44
|
+
- [Contributing, License & Support](#-contributing-license--support)
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## What is AxioDB, and why does it exist?
|
|
26
49
|
|
|
27
|
-
**
|
|
50
|
+
**AxioDB is an embedded NoSQL database for Node.js, with MongoDB-style queries, zero native dependencies, and a built-in web GUI.** Think SQLite, but NoSQL โ install it with npm, and you have a working database with no server, no compilation step, and no platform-specific binaries.
|
|
28
51
|
|
|
29
|
-
### The
|
|
52
|
+
### The problem
|
|
30
53
|
|
|
31
|
-
SQLite is great, but
|
|
54
|
+
SQLite is great, but its native C bindings cause real deployment pain in JavaScript projects:
|
|
32
55
|
|
|
33
56
|
- โ `electron-rebuild` on every Electron update
|
|
34
|
-
- โ Platform-specific builds (Windows
|
|
57
|
+
- โ Platform-specific builds (Windows `.node` files โ Mac `.node` files)
|
|
35
58
|
- โ SQL strings instead of JavaScript objects
|
|
36
59
|
- โ Schema migrations when your data model changes
|
|
37
60
|
- โ `node-gyp` compilation headaches
|
|
38
61
|
|
|
39
|
-
|
|
62
|
+
Meanwhile, plain JSON files have no querying, no caching, and no indexing โ they just don't scale past a few thousand records. And MongoDB solves the query/caching problem, but needs a separate server process, which is overkill for a desktop app, CLI tool, or embedded system.
|
|
40
63
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
64
|
+
### The solution
|
|
65
|
+
|
|
66
|
+
AxioDB combines the parts of each that actually matter for an embedded use case:
|
|
67
|
+
|
|
68
|
+
- โ
Works everywhere Node.js runs โ no rebuild, no native dependencies
|
|
69
|
+
- โ
MongoDB-style queries: `{ age: { $gt: 25 } }`
|
|
70
|
+
- โ
Schema-less JSON documents โ no migrations
|
|
71
|
+
- โ
Built-in `InMemoryCache` with automatic invalidation
|
|
45
72
|
- โ
Multi-core parallelism with Worker Threads
|
|
46
73
|
- โ
Built-in web GUI at `localhost:27018`
|
|
47
|
-
- โ
|
|
74
|
+
- โ
AxioDBCloud โ optional TCP remote access for Docker/cloud deployments
|
|
75
|
+
|
|
76
|
+
### Is it a fit for you?
|
|
77
|
+
|
|
78
|
+
**Great fit for:**
|
|
79
|
+
- ๐ฅ๏ธ Desktop apps (Electron, Tauri)
|
|
80
|
+
- ๐ ๏ธ CLI tools
|
|
81
|
+
- ๐ฆ Embedded systems
|
|
82
|
+
- ๐ Rapid prototyping
|
|
83
|
+
- ๐ Local-first applications
|
|
84
|
+
- ๐ป Node.js apps requiring local storage
|
|
85
|
+
|
|
86
|
+
**Sweet spot:** 10Kโ500K documents with intelligent caching.
|
|
87
|
+
|
|
88
|
+
**Not a fit for:**
|
|
89
|
+
- 10M+ documents, or datasets that need to scale far beyond a single node โ use PostgreSQL, MongoDB, or SQLite
|
|
90
|
+
- Multi-user web applications with hundreds of concurrent connections โ AxioDB is single-instance, not a client-server database
|
|
91
|
+
- Relational data with JOINs and foreign-key constraints โ AxioDB is document-based NoSQL
|
|
92
|
+
- Distributed systems needing replication, sharding, or clustering โ AxioDB is single-node only
|
|
93
|
+
- Cross-collection ACID transactions โ AxioDB's transactions are scoped to a single collection
|
|
94
|
+
|
|
95
|
+
**AxioDB isn't competing with PostgreSQL or MongoDB.** It's for when you need a database *embedded in your app* โ no server setup, no native dependencies. When you outgrow it, migrating to PostgreSQL or MongoDB is the right call, and expected.
|
|
48
96
|
|
|
49
97
|
---
|
|
50
98
|
|
|
51
|
-
##
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
99
|
+
## ๐ฆ Installation
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
npm install axiodb@latest --save
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Requirements:** Node.js โฅ20.0.0, npm โฅ6.0.0 (yarn โฅ1.0.0 optional). AxioDB runs on Node.js servers only โ it requires the filesystem, so it does not run in a browser.
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## ๐ ๏ธ Quick Start โ Local AxioDB
|
|
110
|
+
|
|
111
|
+
```javascript
|
|
112
|
+
const { AxioDB } = require('axiodb');
|
|
113
|
+
|
|
114
|
+
// Create AxioDB instance with the built-in GUI enabled
|
|
115
|
+
const db = new AxioDB({ GUI: true }); // GUI available at http://localhost:27018
|
|
116
|
+
|
|
117
|
+
// Create a database and a collection
|
|
118
|
+
const myDB = await db.createDB('HelloWorldDB');
|
|
119
|
+
const collection = await myDB.createCollection('greetings');
|
|
120
|
+
|
|
121
|
+
// Insert and query โ Hello World! ๐
|
|
122
|
+
await collection.insert({ message: 'Hello, Developer! ๐' });
|
|
123
|
+
const result = await collection.query({}).exec();
|
|
124
|
+
console.log(result.data.documents[0].message); // Hello, Developer! ๐
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
> **Only one `AxioDB` instance per application.** It's a singleton by design โ create it once, then create as many databases and collections as you need under it.
|
|
70
128
|
|
|
71
129
|
---
|
|
72
130
|
|
|
73
|
-
##
|
|
131
|
+
## ๐ Features
|
|
132
|
+
|
|
133
|
+
### Querying
|
|
134
|
+
- **Chainable Query API:** `.query()`, `.Sort()`, `.Limit()`, `.Skip()`, `.setCount()`, `.setProject()`, `.exec()` / `.findOne()`
|
|
135
|
+
- **MongoDB-style Query Operators:** `$gt`, `$gte`, `$lt`, `$lte`, `$ne`, `$in`, `$nin`, `$exists`, `$regex`, `$or`, `$and`
|
|
136
|
+
- **Aggregation Pipelines:** MongoDB-compatible (`$match`, `$group`, `$sort`, `$project`, `$limit`, `$skip`, `$unwind`, `$addFields`, ...)
|
|
137
|
+
- **Bulk Operations:** high-performance `insertMany`, `UpdateMany`, `deleteMany`
|
|
74
138
|
|
|
75
|
-
###
|
|
76
|
-
|
|
77
|
-
- **
|
|
78
|
-
- **
|
|
79
|
-
- **
|
|
80
|
-
- **
|
|
139
|
+
### Indexing
|
|
140
|
+
- **Auto Indexing:** every collection gets an automatic `documentId` index for O(1) lookups
|
|
141
|
+
- **Custom Field Indexes:** `newIndex(...fieldNames)` to add fast lookups on any field, `dropIndex(indexName)` to remove one, `getIndexes()` to list what's registered
|
|
142
|
+
- **Index Cache with TTL:** in-memory index cache with random 5โ15 min TTL (prevents cache stampede) and disk persistence for cold-start recovery
|
|
143
|
+
- **Automatic Document Removal:** documents are automatically removed from indexes when deleted
|
|
144
|
+
- **Dual-Write Pattern:** indexes persist to both memory (speed) and disk (durability)
|
|
145
|
+
|
|
146
|
+
### Transactions
|
|
147
|
+
- **ACID-compliant, single-collection transactions** with savepoints, rollback, and Write-Ahead Logging (WAL) for crash recovery
|
|
148
|
+
- **Session Management:** scoped transactions with timeout support
|
|
81
149
|
|
|
82
150
|
```javascript
|
|
83
|
-
// Transaction example
|
|
84
151
|
const session = collection.startSession();
|
|
85
152
|
await session.withTransaction(async (tx) => {
|
|
86
153
|
await tx.insert({ name: 'Alice', balance: 1000 });
|
|
87
154
|
await tx.update({ name: 'Bob' }, { $inc: { balance: -100 } });
|
|
88
|
-
// Auto-commits on success, auto-
|
|
155
|
+
// Auto-commits on success, auto-rolls-back on error
|
|
89
156
|
});
|
|
90
157
|
```
|
|
91
158
|
|
|
92
|
-
###
|
|
93
|
-
-
|
|
94
|
-
- **
|
|
95
|
-
- **
|
|
96
|
-
- **
|
|
97
|
-
|
|
98
|
-
###
|
|
99
|
-
- **
|
|
100
|
-
- **
|
|
101
|
-
-
|
|
102
|
-
|
|
159
|
+
### Caching
|
|
160
|
+
- **`InMemoryCache`:** automatic eviction policies, random TTL (5โ15 min) to avoid thundering-herd cache expiry
|
|
161
|
+
- **Selective Invalidation:** only the affected cache entries are cleared on update/delete โ not the whole cache
|
|
162
|
+
- **Async, Non-blocking Updates:** cache writes don't block the response path
|
|
163
|
+
- **Collection-Scoped Keys:** cache keys include the collection path, so there's no cross-collection collision
|
|
164
|
+
|
|
165
|
+
### Encryption & Security
|
|
166
|
+
- **AES-256 Encryption:** optional per collection, with an auto-generated or custom key
|
|
167
|
+
- **File-level Isolation:** each document lives in its own `.axiodb` file with locking
|
|
168
|
+
- See [Built-in Web GUI & Authentication](#-built-in-web-gui--authentication-rbac) for RBAC/login and [Security Best Practices](#-best-practices) below
|
|
169
|
+
|
|
170
|
+
### Architecture
|
|
171
|
+
- **Tree-like Storage:** hierarchical, file-per-document layout for efficient retrieval, selective loading, and easy backup
|
|
172
|
+
- **Worker Threads:** non-blocking I/O and multi-core utilization, especially for reads
|
|
173
|
+
- **Single Instance Architecture:** one `AxioDB` instance manages unlimited databases and collections, with strong consistency
|
|
174
|
+
- **Zero-Configuration Setup:** serverless โ install and start building instantly
|
|
175
|
+
- **Custom Database Path:** flexible storage location via `CustomPath`
|
|
176
|
+
|
|
177
|
+
### GUI & Remote Access
|
|
178
|
+
- **Web-based GUI Dashboard:** visual database browser, query execution, real-time monitoring at `localhost:27018`
|
|
179
|
+
- **Role-Based Access Control:** Super Admin / Admin / View roles, shared between the GUI and AxioDBCloud
|
|
180
|
+
- **AxioDBCloud:** TCP-based remote access โ connect to a running AxioDB instance from anywhere with the exact same API as embedded mode
|
|
103
181
|
|
|
104
182
|
---
|
|
105
183
|
|
|
106
|
-
## โ๏ธ AxioDBCloud
|
|
184
|
+
## โ๏ธ AxioDBCloud โ Connecting Remotely
|
|
107
185
|
|
|
108
|
-
**Host AxioDB in Docker, connect from anywhere
|
|
186
|
+
**Host AxioDB in Docker or on a server, connect from anywhere** โ AxioDBCloud is a TCP client that mirrors the embedded API exactly, so switching from local to remote is a one-line change (`new AxioDB()` โ `new AxioDBCloud()`).
|
|
109
187
|
|
|
110
|
-
|
|
188
|
+
- **๐ Zero Code Changes:** same `createDB`/`createCollection`/`insert`/`query` API as embedded AxioDB
|
|
189
|
+
- **โก Fast Binary Protocol:** length-prefixed JSON framing, with automatic reconnection
|
|
190
|
+
- **๐ Optional Authentication:** shared RBAC with the GUI, per-IP rate limiting (see [Advanced](#advanced-tcp-authentication) below)
|
|
191
|
+
- **๐ฆ 35+ Commands:** full CRUD, aggregation, and indexing over the wire
|
|
192
|
+
- **๐ Auto-Reconnect:** exponential backoff, up to 10 retry attempts
|
|
193
|
+
- **๐ Heartbeat Monitoring:** `PING`/`PONG` every 30 seconds
|
|
194
|
+
- **๐ Request Correlation:** UUID-based request/response matching
|
|
195
|
+
- **๐งต Connection Pooling:** supports 1,000+ concurrent connections
|
|
196
|
+
- **๐ TypeScript Support:** full type definitions included
|
|
111
197
|
|
|
112
|
-
|
|
113
|
-
- **๐ Zero Code Changes:** Same API as embedded AxioDB - just change the client class!
|
|
114
|
-
- **โก TCP Protocol:** Fast binary protocol with automatic reconnection
|
|
115
|
-
- **๐ Production Ready:** Connection pooling, heartbeat monitoring, error recovery
|
|
116
|
-
- **๐ฆ Docker Support:** One-command deployment with included Dockerfile
|
|
198
|
+
**Use cases:** microservices sharing one AxioDB instance, Electron apps connecting to a local or remote database, teams sharing a development database, container/cloud deployments (AWS, Azure, GCP, DigitalOcean).
|
|
117
199
|
|
|
118
|
-
###
|
|
200
|
+
### Simple: connect without authentication
|
|
119
201
|
|
|
120
|
-
|
|
121
|
-
# Pull and run the AxioDB Docker container
|
|
122
|
-
docker run -d \
|
|
123
|
-
--name axiodb-server \
|
|
124
|
-
-p 27018:27018 \
|
|
125
|
-
-p 27019:27019 \
|
|
126
|
-
-v axiodb-data:/app \
|
|
127
|
-
theankansaha/axiodb
|
|
128
|
-
|
|
129
|
-
# Ports:
|
|
130
|
-
# 27018 - HTTP GUI Dashboard
|
|
131
|
-
# 27019 - TCP Remote Access (AxioDBCloud)
|
|
132
|
-
# Volume: /app is the main data directory
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
**Or run locally with Node.js:**
|
|
202
|
+
By default, TCP connections are unauthenticated โ anyone who can reach the port can run any command. This is fine for local development or a fully trusted private network.
|
|
136
203
|
|
|
204
|
+
**Server:**
|
|
137
205
|
```javascript
|
|
138
206
|
const { AxioDB } = require('axiodb');
|
|
139
|
-
const db = new AxioDB({ GUI: false, RootName: 'MyDB', CustomPath: '.', TCP: true }); //
|
|
207
|
+
const db = new AxioDB({ GUI: false, RootName: 'MyDB', CustomPath: '.', TCP: true }); // TCP on port 27019
|
|
140
208
|
```
|
|
141
209
|
|
|
142
|
-
|
|
143
|
-
|
|
210
|
+
**Client:**
|
|
144
211
|
```javascript
|
|
145
212
|
const { AxioDBCloud } = require('axiodb');
|
|
146
213
|
|
|
147
|
-
// Connect to remote AxioDB (same API as embedded!)
|
|
148
214
|
const client = new AxioDBCloud("axiodb://localhost:27019");
|
|
149
215
|
await client.connect();
|
|
150
216
|
|
|
151
|
-
// Use exactly like embedded AxioDB
|
|
152
217
|
const db = await client.createDB("ProductionDB");
|
|
153
218
|
const users = await db.createCollection("Users");
|
|
154
219
|
|
|
155
|
-
// All operations work identically
|
|
156
220
|
await users.insert({ name: "Alice", role: "admin" });
|
|
157
221
|
const results = await users.query({ role: "admin" })
|
|
158
222
|
.Limit(10)
|
|
@@ -162,191 +226,211 @@ const results = await users.query({ role: "admin" })
|
|
|
162
226
|
await client.disconnect();
|
|
163
227
|
```
|
|
164
228
|
|
|
165
|
-
###
|
|
166
|
-
|
|
167
|
-
โ
**35+ Commands** - Full CRUD, aggregation, indexing
|
|
168
|
-
โ
**Auto-Reconnect** - Exponential backoff with up to 10 retry attempts
|
|
169
|
-
โ
**Heartbeat Monitoring** - PING/PONG every 30 seconds
|
|
170
|
-
โ
**Request Correlation** - UUID-based request/response matching
|
|
171
|
-
โ
**Connection Pooling** - Supports 1000+ concurrent connections
|
|
172
|
-
โ
**TypeScript Support** - Full type definitions included
|
|
173
|
-
โ
**Zero Breaking Changes** - Existing AxioDB code works unchanged
|
|
229
|
+
### Advanced: TCP authentication
|
|
174
230
|
|
|
175
|
-
|
|
231
|
+
Opt in with `TCPAuth: true` to require a username/password on every connection. This reuses the **exact same accounts and roles** as the GUI's RBAC system (see [Built-in Web GUI & Authentication](#-built-in-web-gui--authentication-rbac)) โ one set of credentials for both.
|
|
176
232
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
- **Cloud Hosting:** Deploy to AWS, Azure, Google Cloud, DigitalOcean
|
|
182
|
-
|
|
183
|
-
๐ **[Full AxioDBCloud Documentation](https://axiodb.in/cloud)** - Setup guides, API reference, Docker examples
|
|
184
|
-
|
|
185
|
-
---
|
|
233
|
+
**Server:**
|
|
234
|
+
```javascript
|
|
235
|
+
const db = new AxioDB({ TCP: true, TCPAuth: true, RootName: 'MyDB', CustomPath: '.' });
|
|
236
|
+
```
|
|
186
237
|
|
|
187
|
-
|
|
238
|
+
**Client โ credentials in the constructor** (recommended; `connect()` authenticates automatically):
|
|
239
|
+
```javascript
|
|
240
|
+
const client = new AxioDBCloud("axiodb://localhost:27019", {
|
|
241
|
+
username: 'admin',
|
|
242
|
+
password: 'admin',
|
|
243
|
+
});
|
|
244
|
+
await client.connect();
|
|
188
245
|
|
|
189
|
-
|
|
246
|
+
console.log(client.authenticatedUser); // { username, role, mustChangePassword }
|
|
247
|
+
```
|
|
190
248
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
| **Multi-core Processing** | โ Single-threaded | โ
Worker Threads |
|
|
198
|
-
| **Built-in GUI** | โ External tools only | โ
Web interface included |
|
|
199
|
-
| **Best For** | 10M+ records, relational data | 10K-500K documents, embedded apps |
|
|
249
|
+
**Client โ authenticate after connecting** (e.g. credentials supplied at runtime):
|
|
250
|
+
```javascript
|
|
251
|
+
const client = new AxioDBCloud("axiodb://localhost:27019");
|
|
252
|
+
await client.connect();
|
|
253
|
+
await client.login('admin', 'admin');
|
|
254
|
+
```
|
|
200
255
|
|
|
201
|
-
|
|
256
|
+
**What's enforced:**
|
|
257
|
+
- Every command except `PING`/`DISCONNECT`/`AUTHENTICATE` requires a prior successful login on that connection.
|
|
258
|
+
- The same role permissions as the GUI apply per command (e.g. a `View`-role user gets `403` on `CREATE_DB`).
|
|
259
|
+
- **Shared per-IP login rate limiter with the GUI:** 5 failed attempts within a trailing 15-minute window locks that IP out for 15 minutes (`429 Too Many Requests`) โ counted across both TCP and GUI login attempts from that IP.
|
|
260
|
+
- **Accounts that still need their forced password change are rejected outright (`403`)**, not allowed through with a warning โ there's no TCP command to change a password today, so log into the GUI (`http://localhost:27018`) to complete it first, or authenticate with an account that already has.
|
|
261
|
+
- If a Super Admin resets a user's password, changes their role, or deletes them via the GUI while that user has an open TCP connection, the TCP connection is immediately forced to re-authenticate on its next command.
|
|
202
262
|
|
|
203
|
-
|
|
204
|
-
| ------- | --------------------- | ------ |
|
|
205
|
-
| **Storage** | Single JSON file | File-per-document |
|
|
206
|
-
| **Caching** | None | InMemoryCache |
|
|
207
|
-
| **Indexing** | None | Auto documentId |
|
|
208
|
-
| **Query Speed** | Linear O(n) | Sub-millisecond O(1) |
|
|
209
|
-
| **Scalability** | Poor | Excellent |
|
|
210
|
-
| **Built-in Query Operators** | None | $gt, $lt, $regex, $in |
|
|
263
|
+
**Known limitations:** the TCP protocol itself is unencrypted (no TLS) โ deploy behind a private network, VPN, or your own TLS termination if connecting over an untrusted network. There's currently no TCP command to change a password; that must go through the GUI.
|
|
211
264
|
|
|
212
|
-
**
|
|
265
|
+
๐ **[Full AxioDBCloud Documentation](https://axiodb.in/cloud)** โ setup guides, API reference, Docker examples
|
|
213
266
|
|
|
214
267
|
---
|
|
215
268
|
|
|
216
|
-
##
|
|
269
|
+
## ๐ง Troubleshooting
|
|
217
270
|
|
|
218
|
-
|
|
219
|
-
- **Secure Storage:** Data stored in `.axiodb` files with file-level isolation and locking
|
|
220
|
-
- **InMemoryCache:** Minimizes disk reads and exposure of sensitive data
|
|
221
|
-
- **Configurable Access Controls:** Protects against unauthorized access
|
|
222
|
-
- **Automatic Cache Invalidation:** Ensures stale data is never served
|
|
271
|
+
### "Not connected to server" right after calling `connect()`
|
|
223
272
|
|
|
224
|
-
|
|
273
|
+
`client.connect()` is asynchronous and must be `await`ed before you use the connection โ it resolves only once the TCP handshake (and, if `TCPAuth` is on, the `AUTHENTICATE` round-trip) has completed.
|
|
225
274
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
275
|
+
```javascript
|
|
276
|
+
// โ Wrong โ races ahead before the connection (and login) finish
|
|
277
|
+
client.connect();
|
|
278
|
+
console.log(client.authenticatedUser); // undefined
|
|
279
|
+
await client.createDB("MyDB"); // "Not connected to server"
|
|
229
280
|
|
|
230
|
-
|
|
281
|
+
// โ
Right
|
|
282
|
+
await client.connect();
|
|
283
|
+
console.log(client.authenticatedUser); // populated
|
|
284
|
+
await client.createDB("MyDB"); // works
|
|
285
|
+
```
|
|
231
286
|
|
|
232
|
-
|
|
287
|
+
### `401` โ "Authentication required..."
|
|
233
288
|
|
|
234
|
-
|
|
289
|
+
You're running with `TCPAuth: true` and sent a command before a successful `AUTHENTICATE`. Either pass `{ username, password }` in the `AxioDBCloud` constructor (auto-authenticates on `connect()`), or call `await client.login(username, password)` yourself before any other command.
|
|
235
290
|
|
|
236
|
-
|
|
291
|
+
### `403` โ "This account must change its password before it can be used over TCP..."
|
|
237
292
|
|
|
238
|
-
|
|
293
|
+
Your credentials are correct, but that account is still flagged for a forced password change (true for the default `admin`/`admin` account, and for any newly created user). Log into the GUI at `http://localhost:27018`, sign in, and complete the password change there โ there's no TCP command for this yet. Then reconnect with the new password, or use a different account that has already completed its change.
|
|
239
294
|
|
|
240
|
-
|
|
241
|
-
// Enable GUI when creating AxioDB instance
|
|
242
|
-
const db = new AxioDB({ GUI: true }); // GUI available at localhost:27018
|
|
295
|
+
### `429` โ "Too many failed login attempts..."
|
|
243
296
|
|
|
244
|
-
|
|
245
|
-
const db = new AxioDB({ GUI: true, RootName: "MyDB", CustomPath: "./custom/path" });
|
|
246
|
-
```
|
|
297
|
+
Five failed logins from your IP within 15 minutes trigger a 15-minute lockout, shared between TCP and the GUI. Double check the credentials you're sending, wait out the cooldown, or fix the underlying typo/config issue causing repeated failures โ there's no way to clear the lockout early.
|
|
247
298
|
|
|
248
|
-
###
|
|
299
|
+
### `403` โ "This is a reserved system database"
|
|
249
300
|
|
|
250
|
-
|
|
251
|
-
- ๐ Real-time data inspection
|
|
252
|
-
- ๐ Query execution interface
|
|
253
|
-
- ๐ Performance monitoring
|
|
254
|
-
- ๐ฏ No external dependencies required
|
|
301
|
+
You (or a client) tried to read/write a database literally named `config` โ that name is reserved for AxioDB's own RBAC storage (`users`/`roles`/`permissions`) and is blocked on both the GUI and TCP, authenticated or not. Use a different database name.
|
|
255
302
|
|
|
256
|
-
|
|
303
|
+
### Connection refused / timeout connecting to `axiodb://host:27019`
|
|
257
304
|
|
|
258
|
-
|
|
305
|
+
- Confirm the server was started with `TCP: true` (or, in Docker, `AXIODB_TCP=true`, the default).
|
|
306
|
+
- Confirm the port is published: `-p 27019:27019` on `docker run`, or that nothing else on the host is bound to 27019.
|
|
307
|
+
- If you're getting a protocol error mentioning "Message exceeds maximum size" or "Received HTTP data on TCP port," you're likely pointed at the GUI port (27018) instead of the TCP port (27019) โ check your connection string.
|
|
259
308
|
|
|
260
|
-
|
|
309
|
+
### Docker container issues (won't start, port conflicts, data not persisting)
|
|
261
310
|
|
|
262
|
-
|
|
263
|
-
Username: admin
|
|
264
|
-
Password: admin
|
|
265
|
-
```
|
|
311
|
+
See the [Docker Deployment](#-docker-deployment) section below, and `Docker/README.md` in the repository for a fuller Docker-specific troubleshooting guide (`docker logs`, port-conflict remapping, volume-mounting checklist).
|
|
266
312
|
|
|
267
|
-
|
|
313
|
+
---
|
|
268
314
|
|
|
269
|
-
|
|
270
|
-
|------|--------|
|
|
271
|
-
| **Super Admin** | Full access, including creating users/roles |
|
|
272
|
-
| **Admin** | Full database/collection/document access, no user or role management |
|
|
273
|
-
| **View** | Read-only access to databases, collections, and documents |
|
|
315
|
+
## ๐ณ Docker Deployment
|
|
274
316
|
|
|
275
|
-
|
|
317
|
+
### Simple: run the container
|
|
276
318
|
|
|
277
|
-
|
|
319
|
+
```bash
|
|
320
|
+
docker run -d \
|
|
321
|
+
--name axiodb-server \
|
|
322
|
+
-p 27018:27018 \
|
|
323
|
+
-p 27019:27019 \
|
|
324
|
+
-e AXIODB_TCP_AUTH=true \
|
|
325
|
+
-v axiodb-data:/app \
|
|
326
|
+
theankansaha/axiodb
|
|
278
327
|
|
|
279
|
-
|
|
328
|
+
# Ports:
|
|
329
|
+
# 27018 - HTTP GUI Dashboard
|
|
330
|
+
# 27019 - TCP Remote Access (AxioDBCloud)
|
|
331
|
+
# Volume: /app is the main data directory
|
|
332
|
+
```
|
|
280
333
|
|
|
281
|
-
|
|
334
|
+
TCP authentication is on by default in the image. Log into the GUI at `http://localhost:27018` as `admin`/`admin` to complete the forced password change before connecting over TCP (see [Troubleshooting](#-troubleshooting) if you skip this step).
|
|
282
335
|
|
|
283
|
-
###
|
|
336
|
+
### Advanced: env vars, volumes, Compose
|
|
284
337
|
|
|
285
|
-
|
|
338
|
+
Every option below has a default matching the image's previous fixed behavior โ override any of them with `-e VAR=value` at `docker run` time, no rebuild required:
|
|
286
339
|
|
|
287
|
-
|
|
340
|
+
| Variable | Default | Description |
|
|
341
|
+
| --- | --- | --- |
|
|
342
|
+
| `AXIODB_GUI` | `true` | Enable the HTTP Control Server / web GUI on port 27018 |
|
|
343
|
+
| `AXIODB_TCP` | `true` | Enable the AxioDBCloud TCP server on port 27019 |
|
|
344
|
+
| `AXIODB_TCP_AUTH` | `true` | Require username/password authentication on TCP connections (same RBAC accounts as the GUI) |
|
|
345
|
+
| `AXIODB_ROOT_NAME` | `AxioDB` | Name of the root database folder created under the data volume |
|
|
346
|
+
| `AXIODB_CUSTOM_PATH` | *(container's working directory)* | Custom path for database storage inside the container |
|
|
288
347
|
|
|
289
|
-
|
|
348
|
+
> Ports themselves (27018/27019) aren't configurable via environment variable โ remap them at the Docker layer with `-p <host-port>:27018` / `-p <host-port>:27019`.
|
|
290
349
|
|
|
291
|
-
|
|
350
|
+
**Disabling TCP authentication** (only on a trusted private network โ the wire is unencrypted; see [Known limitations](#advanced-tcp-authentication)):
|
|
351
|
+
```bash
|
|
352
|
+
docker run -d \
|
|
353
|
+
--name axiodb-server \
|
|
354
|
+
-p 27018:27018 \
|
|
355
|
+
-p 27019:27019 \
|
|
356
|
+
-e AXIODB_TCP_AUTH=false \
|
|
357
|
+
-v axiodb-data:/app \
|
|
358
|
+
theankansaha/axiodb
|
|
359
|
+
```
|
|
292
360
|
|
|
293
|
-
|
|
361
|
+
**Docker Compose:**
|
|
362
|
+
```yaml
|
|
363
|
+
version: "3.8"
|
|
364
|
+
|
|
365
|
+
services:
|
|
366
|
+
axiodb:
|
|
367
|
+
image: theankansaha/axiodb
|
|
368
|
+
container_name: axiodb-server
|
|
369
|
+
ports:
|
|
370
|
+
- "27018:27018"
|
|
371
|
+
- "27019:27019"
|
|
372
|
+
environment:
|
|
373
|
+
- AXIODB_GUI=true
|
|
374
|
+
- AXIODB_TCP=true
|
|
375
|
+
- AXIODB_TCP_AUTH=true
|
|
376
|
+
- AXIODB_ROOT_NAME=AxioDB
|
|
377
|
+
volumes:
|
|
378
|
+
- axiodb-data:/app
|
|
379
|
+
restart: unless-stopped
|
|
380
|
+
|
|
381
|
+
volumes:
|
|
382
|
+
axiodb-data:
|
|
383
|
+
```
|
|
294
384
|
|
|
295
|
-
|
|
385
|
+
**Building the image from source, and a fuller Docker troubleshooting guide** (container won't start, port-in-use, data-persistence checks) live in [`Docker/README.md`](Docker/README.md) โ the canonical Docker doc, not duplicated here in full.
|
|
296
386
|
|
|
297
|
-
|
|
387
|
+
---
|
|
298
388
|
|
|
299
|
-
|
|
389
|
+
## ๐จ Built-in Web GUI & Authentication (RBAC)
|
|
300
390
|
|
|
301
|
-
|
|
391
|
+
AxioDB includes a built-in web-based GUI for database visualization and management โ perfect for Electron apps and development environments.
|
|
302
392
|
|
|
303
|
-
###
|
|
393
|
+
### Enabling the GUI
|
|
304
394
|
|
|
305
|
-
|
|
395
|
+
```javascript
|
|
396
|
+
// Enable GUI when creating the AxioDB instance
|
|
397
|
+
const db = new AxioDB({ GUI: true }); // GUI available at localhost:27018
|
|
306
398
|
|
|
307
|
-
|
|
399
|
+
// With a custom database path
|
|
400
|
+
const db = new AxioDB({ GUI: true, RootName: "MyDB", CustomPath: "./custom/path" });
|
|
401
|
+
```
|
|
308
402
|
|
|
309
|
-
|
|
403
|
+
**GUI Features:** visual database and collection browser, real-time data inspection, query execution interface, performance monitoring, no external dependencies required. Access at `http://localhost:27018` when enabled.
|
|
310
404
|
|
|
311
|
-
|
|
405
|
+
### Authentication & Access Control
|
|
312
406
|
|
|
313
|
-
|
|
407
|
+
The Control Server ships with built-in login and role-based access control (RBAC) โ the same system TCP's [`TCPAuth`](#advanced-tcp-authentication) reuses. On first start with `GUI: true` (or `TCP: true, TCPAuth: true`), AxioDB seeds a reserved `config` database (hidden from the regular database list) containing three collections โ `users`, `roles`, `permissions` โ and a default account:
|
|
314
408
|
|
|
315
|
-
```
|
|
316
|
-
|
|
409
|
+
```
|
|
410
|
+
Username: admin
|
|
411
|
+
Password: admin
|
|
317
412
|
```
|
|
318
413
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
## ๐ ๏ธ Quick Start
|
|
322
|
-
|
|
323
|
-
### Hello World in 30 Seconds
|
|
414
|
+
You'll be forced to change this password on first login (this applies to every account, not just the default one โ there's currently no way around it other than completing the change via the GUI). Three predefined roles are seeded automatically:
|
|
324
415
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
416
|
+
| Role | Access |
|
|
417
|
+
|------|--------|
|
|
418
|
+
| **Super Admin** | Full access, including creating users/roles |
|
|
419
|
+
| **Admin** | Full database/collection/document access, no user or role management |
|
|
420
|
+
| **View** | Read-only access to databases, collections, documents, and indexes |
|
|
328
421
|
|
|
329
|
-
|
|
330
|
-
const db = new AxioDB({ GUI: true }); // Enable GUI at localhost:27018
|
|
422
|
+
A Super Admin can create additional roles from the predefined permission catalogue and create new users with any role. Sessions are held only in server memory (never persisted to disk) and are tied to an httpOnly cookie, so restarting the server logs everyone out.
|
|
331
423
|
|
|
332
|
-
|
|
333
|
-
const myDB = await db.createDB('HelloWorldDB');
|
|
334
|
-
const collection = await myDB.createCollection('greetings', false);
|
|
424
|
+
**Login rate limiting:** after 5 failed login attempts from the same IP within a trailing 15-minute window, that IP is locked out for 15 minutes (`429 Too Many Requests`) โ regardless of username. This limiter is shared with [TCP `AUTHENTICATE` attempts](#advanced-tcp-authentication) (see [Troubleshooting](#-troubleshooting) for what the error looks like).
|
|
335
425
|
|
|
336
|
-
|
|
337
|
-
await collection.insert({ message: 'Hello, Developer! ๐' });
|
|
338
|
-
const result = await collection.findAll();
|
|
339
|
-
console.log(result[0].message); // Hello, Developer! ๐
|
|
340
|
-
```
|
|
426
|
+
**Index management:** the Control Server also exposes `GET /api/index/list`, `POST /api/index/create`, and `DELETE /api/index/delete`, gated by the same `index:view` / `index:create` / `index:delete` permissions (View role gets view-only, Admin and Super Admin get all three).
|
|
341
427
|
|
|
342
|
-
**
|
|
428
|
+
> **Security note:** RBAC protects the Control Server's HTTP API and TCP server; both are still intended for trusted local/network access, not public internet exposure. See [Troubleshooting](#-troubleshooting) for the TLS caveat on TCP.
|
|
343
429
|
|
|
344
430
|
---
|
|
345
431
|
|
|
346
432
|
## ๐ ๏ธ Detailed Usage
|
|
347
433
|
|
|
348
|
-
> **Important:** Only one AxioDB instance should be initialized per application for consistency and security.
|
|
349
|
-
|
|
350
434
|
### Collection Creation Options
|
|
351
435
|
|
|
352
436
|
```javascript
|
|
@@ -365,10 +449,10 @@ const db = new AxioDB();
|
|
|
365
449
|
|
|
366
450
|
const userDB = await db.createDB("MyDB");
|
|
367
451
|
|
|
368
|
-
// Create basic collection
|
|
452
|
+
// Create a basic collection
|
|
369
453
|
const userCollection = await userDB.createCollection("Users");
|
|
370
454
|
|
|
371
|
-
// Create encrypted collection with custom key
|
|
455
|
+
// Create an encrypted collection with a custom key
|
|
372
456
|
const secureCollection = await userDB.createCollection(
|
|
373
457
|
"SecureUsers",
|
|
374
458
|
true,
|
|
@@ -386,24 +470,59 @@ const results = await userCollection
|
|
|
386
470
|
.Limit(10)
|
|
387
471
|
.Sort({ age: 1 })
|
|
388
472
|
.exec();
|
|
389
|
-
console.log(results);
|
|
473
|
+
console.log(results.data.documents);
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
### Worked example: e-commerce product catalog
|
|
477
|
+
|
|
478
|
+
```javascript
|
|
479
|
+
const { AxioDB } = require('axiodb');
|
|
480
|
+
const db = new AxioDB();
|
|
481
|
+
|
|
482
|
+
const shopDB = await db.createDB('ecommerce');
|
|
483
|
+
const products = await shopDB.createCollection('products');
|
|
484
|
+
|
|
485
|
+
await products.insert({
|
|
486
|
+
name: 'Laptop',
|
|
487
|
+
price: 999.99,
|
|
488
|
+
category: 'Electronics',
|
|
489
|
+
inStock: true,
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
// Sorted, filtered query
|
|
493
|
+
const electronics = await products
|
|
494
|
+
.query({ category: 'Electronics', inStock: true })
|
|
495
|
+
.Sort({ price: 1 })
|
|
496
|
+
.exec();
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
### Worked example: encrypted user records
|
|
500
|
+
|
|
501
|
+
```javascript
|
|
502
|
+
const users = await db.createCollection(
|
|
503
|
+
'users',
|
|
504
|
+
true, // encrypted
|
|
505
|
+
process.env.USER_ENCRYPTION_KEY, // custom key from env โ see Best Practices below
|
|
506
|
+
);
|
|
507
|
+
|
|
508
|
+
await users.insert({
|
|
509
|
+
username: 'johndoe',
|
|
510
|
+
email: 'john@example.com',
|
|
511
|
+
passwordHash: hashedPassword,
|
|
512
|
+
createdAt: new Date(),
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
const user = await users.query({ username: 'johndoe' }).exec();
|
|
390
516
|
```
|
|
391
517
|
|
|
392
518
|
---
|
|
393
519
|
|
|
394
520
|
## ๐ Advanced Features
|
|
395
521
|
|
|
396
|
-
- **Multiple Databases:**
|
|
397
|
-
- **
|
|
398
|
-
- **
|
|
399
|
-
- **
|
|
400
|
-
- **Flexible Collection Types:** Basic or encrypted
|
|
401
|
-
- **Custom Query Operators:** `$gt`, `$lt`, `$in`, `$regex`, `$gte`, `$lte`, `$ne`, `$nin`, `$exists`, `$or`, `$and`
|
|
402
|
-
- **Schema-less Design:** Store any JSON structure without predefined schemas
|
|
403
|
-
- **Performance Optimization:** Fast lookups, pagination, and intelligent caching with random TTL
|
|
404
|
-
- **ACID Transactions:** Single-collection transactions with savepoints, rollback, and WAL recovery
|
|
405
|
-
- **Index Management:** Create custom indexes, automatic document-to-index sync on CRUD operations
|
|
406
|
-
- **Enterprise Data Management:** Bulk operations, conditional updates, atomic transactions
|
|
522
|
+
- **Multiple Databases:** architect scalable apps with multiple databases and collections, each with independent security settings
|
|
523
|
+
- **Custom Query Processing:** the full operator set (`$gt`, `$lt`, `$in`, `$regex`, `$gte`, `$lte`, `$ne`, `$nin`, `$exists`, `$or`, `$and`) plus aggregation pipelines
|
|
524
|
+
- **Enterprise Data Management:** bulk operations, conditional updates, atomic transactions
|
|
525
|
+
- **Performance Optimization:** fast lookups, pagination, and intelligent caching with random TTL
|
|
407
526
|
|
|
408
527
|
---
|
|
409
528
|
|
|
@@ -411,7 +530,7 @@ console.log(results);
|
|
|
411
530
|
|
|
412
531
|
### AxioDB
|
|
413
532
|
|
|
414
|
-
- `createDB(dbName: string
|
|
533
|
+
- `createDB(dbName: string): Promise<Database>`
|
|
415
534
|
- `deleteDatabase(dbName: string): Promise<SuccessInterface | ErrorInterface>`
|
|
416
535
|
|
|
417
536
|
### Database
|
|
@@ -429,8 +548,9 @@ console.log(results);
|
|
|
429
548
|
- `delete(query: object): Deleter`
|
|
430
549
|
- `aggregate(pipeline: object[]): Aggregation`
|
|
431
550
|
- `startSession(options?: SessionOptions): Session`
|
|
432
|
-
- `
|
|
551
|
+
- `newIndex(...fieldNames: string[]): Promise<SuccessInterface>`
|
|
433
552
|
- `dropIndex(indexName: string): Promise<SuccessInterface | ErrorInterface>`
|
|
553
|
+
- `getIndexes(): Promise<SuccessInterface | ErrorInterface>` โ lists all indexes registered on the collection
|
|
434
554
|
|
|
435
555
|
### Reader
|
|
436
556
|
|
|
@@ -457,45 +577,95 @@ console.log(results);
|
|
|
457
577
|
|
|
458
578
|
---
|
|
459
579
|
|
|
460
|
-
##
|
|
580
|
+
## โ
Best Practices
|
|
461
581
|
|
|
462
|
-
**
|
|
463
|
-
- ๐ฅ๏ธ Desktop apps (Electron, Tauri)
|
|
464
|
-
- ๐ ๏ธ CLI tools
|
|
465
|
-
- ๐ฆ Embedded systems
|
|
466
|
-
- ๐ Rapid prototyping
|
|
467
|
-
- ๐ Local-first applications
|
|
468
|
-
- ๐ป Node.js apps requiring local storage
|
|
582
|
+
**Use environment variables for encryption keys and TCP credentials โ never hardcode them:**
|
|
469
583
|
|
|
470
|
-
|
|
584
|
+
```javascript
|
|
585
|
+
// โ Bad
|
|
586
|
+
const collection = await db.createCollection('data', true, 'myKey123');
|
|
471
587
|
|
|
472
|
-
|
|
588
|
+
// โ
Good
|
|
589
|
+
const collection = await db.createCollection(
|
|
590
|
+
'data',
|
|
591
|
+
true,
|
|
592
|
+
process.env.AXIODB_ENCRYPTION_KEY,
|
|
593
|
+
);
|
|
594
|
+
```
|
|
595
|
+
|
|
596
|
+
**Use `documentId` for the fastest possible lookups** โ it's the one field that's always indexed automatically, backed by `InMemoryCache`:
|
|
597
|
+
|
|
598
|
+
```javascript
|
|
599
|
+
const user = await collection.query({ documentId: 'ABC123' }).exec();
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
**Handle errors explicitly** โ AxioDB operations reject/return error responses rather than throwing silently:
|
|
603
|
+
|
|
604
|
+
```javascript
|
|
605
|
+
try {
|
|
606
|
+
await collection.insert({ name: 'User' });
|
|
607
|
+
} catch (error) {
|
|
608
|
+
console.error('Insert failed:', error);
|
|
609
|
+
}
|
|
610
|
+
```
|
|
473
611
|
|
|
474
|
-
|
|
612
|
+
**Clean up resources you no longer need:**
|
|
613
|
+
|
|
614
|
+
```javascript
|
|
615
|
+
await database.deleteCollection('tempCollection');
|
|
616
|
+
await db.deleteDatabase('tempDB');
|
|
617
|
+
```
|
|
475
618
|
|
|
476
|
-
**
|
|
619
|
+
**Encryption & access control:**
|
|
620
|
+
- Use strong, unique encryption keys
|
|
621
|
+
- Never hardcode keys โ use environment variables or a secrets manager
|
|
622
|
+
- Implement proper access controls and take regular backups
|
|
623
|
+
- For AxioDBCloud/GUI, rotate the default `admin` password immediately (see [Authentication & Access Control](#-built-in-web-gui--authentication-rbac))
|
|
477
624
|
|
|
478
|
-
|
|
625
|
+
For vulnerability reporting, see [SECURITY.md](SECURITY.md).
|
|
479
626
|
|
|
480
627
|
---
|
|
481
628
|
|
|
482
|
-
##
|
|
629
|
+
## โ๏ธ Architecture & Internal Mechanisms
|
|
483
630
|
|
|
484
|
-
|
|
631
|
+
- **Tree Structure for Fast Data Retrieval:** hierarchical storage enables O(1) document lookups and efficient indexing. Each document is isolated in its own file, supporting selective loading and easy backup.
|
|
632
|
+
- **Worker Threads for Parallel Processing:** leverages Node.js Worker Threads for non-blocking I/O, multi-core utilization, and scalable performance โ especially for read operations.
|
|
633
|
+
- **Two-Pointer Searching Algorithm:** optimized for range queries and filtered searches, minimizing memory usage and computational overhead.
|
|
634
|
+
- **`InMemoryCache` System:** automatic eviction policies, TTL support, and memory optimization, delivering sub-millisecond response times for frequently accessed data.
|
|
635
|
+
- **Query Processing Pipeline:** intelligent caching, parallelized processing, lazy evaluation, and just-in-time query optimization.
|
|
636
|
+
- **Single Instance Architecture:** ensures ACID compliance, strong data consistency, and simplified deployment โ one `AxioDB` instance manages all databases and collections.
|
|
637
|
+
- **Designed for Node.js Developers:** native JavaScript API, promise-based interface, lightweight dependency footprint, simple learning curve.
|
|
485
638
|
|
|
486
|
-
|
|
639
|
+
---
|
|
487
640
|
|
|
488
|
-
|
|
641
|
+
## ๐ Comparisons
|
|
489
642
|
|
|
490
|
-
|
|
643
|
+
### AxioDB vs SQLite
|
|
491
644
|
|
|
492
|
-
|
|
645
|
+
| Feature | SQLite | AxioDB |
|
|
646
|
+
| ------- | ------ | ------ |
|
|
647
|
+
| **Native Dependencies** | โ Yes (C bindings) | โ
Pure JavaScript |
|
|
648
|
+
| **Query Language** | SQL Strings | JavaScript Objects |
|
|
649
|
+
| **Schema Migrations** | โ Required (ALTER TABLE) | โ
Schema-less |
|
|
650
|
+
| **Built-in Caching** | โ ๏ธ Manual | โ
InMemoryCache |
|
|
651
|
+
| **Multi-core Processing** | โ Single-threaded | โ
Worker Threads |
|
|
652
|
+
| **Built-in GUI** | โ External tools only | โ
Web interface included |
|
|
653
|
+
| **Best For** | 10M+ records, relational data | 10Kโ500K documents, embedded apps |
|
|
493
654
|
|
|
494
|
-
|
|
655
|
+
### AxioDB vs Traditional JSON Files
|
|
495
656
|
|
|
496
|
-
|
|
657
|
+
| Feature | Traditional JSON Files | AxioDB |
|
|
658
|
+
| ------- | --------------------- | ------ |
|
|
659
|
+
| **Storage** | Single JSON file | File-per-document |
|
|
660
|
+
| **Caching** | None | InMemoryCache |
|
|
661
|
+
| **Indexing** | None | Auto `documentId` + custom fields |
|
|
662
|
+
| **Query Speed** | Linear O(n) | Sub-millisecond O(1) |
|
|
663
|
+
| **Scalability** | Poor | Excellent (up to sweet spot) |
|
|
664
|
+
| **Built-in Query Operators** | None | `$gt`, `$lt`, `$regex`, `$in`, ... |
|
|
665
|
+
|
|
666
|
+
**Benchmark:** AxioDB's `documentId` search with `InMemoryCache` provides instant retrieval compared to traditional JSON files, which require full-file parsing (tested with 1M+ documents).
|
|
497
667
|
|
|
498
|
-
|
|
668
|
+
### AxioDB vs lowdb, nedb, better-sqlite3
|
|
499
669
|
|
|
500
670
|
| Feature | lowdb | nedb | better-sqlite3 | AxioDB |
|
|
501
671
|
|---------|-------|------|---------------|--------|
|
|
@@ -515,109 +685,71 @@ When you outgrow AxioDB (1M+ documents, distributed systems), migrate to Postgre
|
|
|
515
685
|
|
|
516
686
|
---
|
|
517
687
|
|
|
688
|
+
## โ ๏ธ Limitations & Honest Positioning
|
|
689
|
+
|
|
690
|
+
- **Dataset Size:** optimized for 10Kโ500K documents. For 10M+, use PostgreSQL, MongoDB, or SQLite.
|
|
691
|
+
- **Concurrency:** single-instance architecture. For multi-user web apps with hundreds of concurrent connections, use a traditional client-server database.
|
|
692
|
+
- **Relational Data:** document-based NoSQL, no JOIN operations. For complex relational data with foreign keys, use a SQL database.
|
|
693
|
+
- **Distributed Systems:** single-node only โ no replication, sharding, or clustering. Use MongoDB or CouchDB for that.
|
|
694
|
+
- **Transactions:** single-collection ACID transactions only. For cross-collection transaction requirements, use PostgreSQL or MongoDB.
|
|
695
|
+
|
|
696
|
+
None of this is a shortcoming to apologize for โ AxioDB is deliberately scoped to the embedded/local-first niche. When you outgrow it, that's a sign to migrate, not a bug to file.
|
|
697
|
+
|
|
698
|
+
---
|
|
699
|
+
|
|
518
700
|
## โ FAQ
|
|
519
701
|
|
|
520
702
|
**Q: What is AxioDB?**
|
|
521
|
-
An embedded NoSQL database for Node.js. Pure JavaScript, zero native dependencies. `npm install axiodb` and you have a database โ no server, no node-gyp
|
|
703
|
+
An embedded NoSQL database for Node.js. Pure JavaScript, zero native dependencies. `npm install axiodb` and you have a database โ no server, no `node-gyp`, no `electron-rebuild`.
|
|
522
704
|
|
|
523
705
|
**Q: Is AxioDB a replacement for MongoDB?**
|
|
524
|
-
No. AxioDB is embedded (runs inside your app)
|
|
706
|
+
No. AxioDB is embedded (runs inside your app); MongoDB is a client-server database for multi-user systems. Use AxioDB for desktop apps, CLI tools, and local-first apps up to ~500K documents; use MongoDB when you need a shared networked database.
|
|
525
707
|
|
|
526
708
|
**Q: Does AxioDB work with Electron?**
|
|
527
709
|
Yes โ this is the primary use case it was built for. Zero native dependencies means no `electron-rebuild`, no platform-specific `.node` files, no compilation step.
|
|
528
710
|
|
|
529
|
-
**Q:
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
**Q: What is the difference between AxioDB and lowdb?**
|
|
533
|
-
`lowdb` stores everything in a single JSON file โ it gets slow above 1,000โ5,000 records because every read parses the entire file. AxioDB uses file-per-document storage, InMemoryCache, Worker Threads, and auto-indexing โ optimized for 10Kโ500K documents with O(1) lookups by documentId.
|
|
534
|
-
|
|
535
|
-
**Q: What is the difference between AxioDB and nedb?**
|
|
536
|
-
NeDB is abandoned since 2016. AxioDB is actively maintained with TypeScript, ACID transactions, Worker Threads, AES-256 encryption, custom field indexing, built-in GUI, and AxioDBCloud remote access.
|
|
711
|
+
**Q: How does AxioDB compare to better-sqlite3 / lowdb / nedb?**
|
|
712
|
+
See the [Comparisons](#-comparisons) tables above for the full breakdown โ in short: no native bindings (unlike better-sqlite3), no single-file bottleneck (unlike lowdb), and actively maintained with TypeScript/transactions/encryption (unlike the abandoned nedb).
|
|
537
713
|
|
|
538
714
|
**Q: How many documents can AxioDB handle?**
|
|
539
|
-
Optimized for 10,000โ500,000 documents. For 1M+, use PostgreSQL or MongoDB. documentId lookups take ~1ms on 10K documents with InMemoryCache
|
|
715
|
+
Optimized for 10,000โ500,000 documents. For 1M+, use PostgreSQL or MongoDB. `documentId` lookups take ~1ms on 10K documents with `InMemoryCache`.
|
|
540
716
|
|
|
541
717
|
**Q: Does AxioDB support TypeScript?**
|
|
542
718
|
Yes. Full type definitions are included โ no separate `@types` package needed.
|
|
543
719
|
|
|
544
720
|
**Q: Does AxioDB work in the browser?**
|
|
545
|
-
No. AxioDB requires Node.js (v20+) and the filesystem
|
|
721
|
+
No. AxioDB requires Node.js (v20+) and the filesystem โ server-side and desktop only.
|
|
546
722
|
|
|
547
723
|
**Q: What is AxioDBCloud?**
|
|
548
|
-
TCP-based remote access for AxioDB. Deploy AxioDB in Docker, connect from multiple clients with the exact same API. Supports 1,000+ concurrent connections with auto-reconnect.
|
|
549
|
-
|
|
550
|
-
---
|
|
551
|
-
|
|
552
|
-
## ๐ฎ Future Roadmap
|
|
553
|
-
|
|
554
|
-
- **Data Export & Import:** Seamless data migration with support for JSON, CSV, and native AxioDB formats
|
|
555
|
-
- **Enhanced Web GUI:** Advanced web interface with real-time analytics, visual query builder, and performance monitoring
|
|
556
|
-
- **Comprehensive Documentation:** Extensive tutorials, interactive examples, and complete API references for all skill levels
|
|
557
|
-
- **Performance Optimizations:** Continued improvements to query performance and caching strategies
|
|
558
|
-
|
|
559
|
-
---
|
|
560
|
-
|
|
561
|
-
## ๐ค Contributing
|
|
562
|
-
|
|
563
|
-
We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
564
|
-
|
|
565
|
-
---
|
|
566
|
-
|
|
567
|
-
## ๐ License
|
|
568
|
-
|
|
569
|
-
MIT License. See [LICENSE](LICENSE).
|
|
570
|
-
|
|
571
|
-
---
|
|
572
|
-
|
|
573
|
-
## ๐ Acknowledgments
|
|
574
|
-
|
|
575
|
-
Special thanks to all contributors and supporters of AxioDB. Your feedback and contributions make this project better!
|
|
724
|
+
TCP-based remote access for AxioDB. Deploy AxioDB in Docker, connect from multiple clients with the exact same API. Supports 1,000+ concurrent connections with auto-reconnect. Optional username/password authentication (`TCPAuth: true`) reuses the same RBAC accounts as the GUI โ see [AxioDBCloud](#-axiodbcloud--connecting-remotely) above.
|
|
576
725
|
|
|
577
726
|
---
|
|
578
727
|
|
|
579
|
-
##
|
|
580
|
-
|
|
581
|
-
- **Node.js:** >=20.0.0
|
|
582
|
-
- **npm:** >=6.0.0
|
|
583
|
-
- **yarn:** >=1.0.0 (optional)
|
|
584
|
-
|
|
585
|
-
---
|
|
728
|
+
## ๐ค Contributing, License & Support
|
|
586
729
|
|
|
587
|
-
|
|
730
|
+
**Contributing:** we welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
588
731
|
|
|
589
|
-
|
|
590
|
-
- **React 18** with TypeScript
|
|
591
|
-
- **Vite** for fast development and building
|
|
592
|
-
- **TailwindCSS** for styling
|
|
593
|
-
- **Lucide React** for icons
|
|
732
|
+
**License:** MIT. See [LICENSE](LICENSE).
|
|
594
733
|
|
|
595
|
-
|
|
734
|
+
**Requirements:** Node.js โฅ20.0.0, npm โฅ6.0.0, yarn โฅ1.0.0 (optional).
|
|
596
735
|
|
|
736
|
+
**Documentation website:** built with React 18 + TypeScript, Vite, TailwindCSS, and Lucide React. To run it locally:
|
|
597
737
|
```bash
|
|
598
738
|
cd Document
|
|
599
739
|
npm install
|
|
600
740
|
npm run dev
|
|
601
741
|
```
|
|
742
|
+
Available at `http://localhost:5173`.
|
|
602
743
|
|
|
603
|
-
|
|
744
|
+
**Author:** Ankan Saha
|
|
604
745
|
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
746
|
+
**Support the project:**
|
|
747
|
+
- โญ Star the repository
|
|
748
|
+
- ๐ Report issues
|
|
749
|
+
- ๐ก Suggest features
|
|
750
|
+
- ๐ค Contribute code
|
|
751
|
+
- ๐ฐ [Sponsor the project](https://github.com/sponsors/AnkanSaha)
|
|
608
752
|
|
|
609
|
-
**
|
|
753
|
+
**Acknowledgments:** special thanks to all contributors and supporters of AxioDB โ your feedback and contributions make this project better.
|
|
610
754
|
|
|
611
755
|
---
|
|
612
|
-
|
|
613
|
-
## ๐ Support
|
|
614
|
-
|
|
615
|
-
If you find AxioDB helpful, consider:
|
|
616
|
-
- โญ Starring the repository
|
|
617
|
-
- ๐ Reporting issues
|
|
618
|
-
- ๐ก Suggesting features
|
|
619
|
-
- ๐ค Contributing code
|
|
620
|
-
- ๐ฐ [Sponsoring the project](https://github.com/sponsors/AnkanSaha)
|
|
621
|
-
|
|
622
|
-
---
|
|
623
|
-
|