axiodb 11.9.12 โ 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 +423 -334
- 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
|
-
- **Bulk Operations:** High-performance bulk insert, update, and delete operations (`insertMany`, `UpdateMany`, `DeleteMany`)
|
|
59
|
-
- **Tree-like Structure:** Hierarchical data storage for efficient retrieval and organization
|
|
60
|
-
- **Auto Indexing:** Optimized indexes on document IDs for lightning-fast queries
|
|
61
|
-
- **Index Cache with TTL:** In-memory index cache with automatic expiration (5-15 min random TTL) and disk persistence
|
|
62
|
-
- **Selective Cache Invalidation:** Smart cache invalidation that only clears affected entries on updates/deletes
|
|
63
|
-
- **Transaction Support:** ACID-compliant transactions with savepoints, rollback, and Write-Ahead Logging (WAL)
|
|
64
|
-
- **Single Instance Architecture:** Unified management for unlimited databases, collections, and documents
|
|
65
|
-
- **Web-Based GUI Dashboard:** Visual database administration, query execution, and real-time monitoring at `localhost:27018`
|
|
66
|
-
- **Role-Based Access Control:** Built-in login for the Control Server with Super Admin/Admin/View roles and per-permission enforcement
|
|
67
|
-
- **AxioDBCloud Remote Access:** TCP-based client for connecting to AxioDB from anywhereโDocker, Cloud, or local network
|
|
68
|
-
- **Zero-Configuration Setup:** Serverless architectureโinstall and start building instantly
|
|
69
|
-
- **Custom Database Path:** Flexible storage locations for better project organization
|
|
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.
|
|
70
106
|
|
|
71
107
|
---
|
|
72
108
|
|
|
73
|
-
##
|
|
109
|
+
## ๐ ๏ธ Quick Start โ Local AxioDB
|
|
74
110
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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.
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
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`
|
|
138
|
+
|
|
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
|
|
117
|
-
|
|
118
|
-
### Quick Start - Server (Docker)
|
|
119
|
-
|
|
120
|
-
```bash
|
|
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
|
|
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).
|
|
128
199
|
|
|
129
|
-
|
|
130
|
-
# 27018 - HTTP GUI Dashboard
|
|
131
|
-
# 27019 - TCP Remote Access (AxioDBCloud)
|
|
132
|
-
# Volume: /app is the main data directory
|
|
133
|
-
```
|
|
200
|
+
### Simple: connect without authentication
|
|
134
201
|
|
|
135
|
-
|
|
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,17 +226,17 @@ const results = await users.query({ role: "admin" })
|
|
|
162
226
|
await client.disconnect();
|
|
163
227
|
```
|
|
164
228
|
|
|
165
|
-
###
|
|
229
|
+
### Advanced: TCP authentication
|
|
166
230
|
|
|
167
|
-
|
|
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.
|
|
168
232
|
|
|
233
|
+
**Server:**
|
|
169
234
|
```javascript
|
|
170
|
-
// Server
|
|
171
235
|
const db = new AxioDB({ TCP: true, TCPAuth: true, RootName: 'MyDB', CustomPath: '.' });
|
|
172
236
|
```
|
|
173
237
|
|
|
238
|
+
**Client โ credentials in the constructor** (recommended; `connect()` authenticates automatically):
|
|
174
239
|
```javascript
|
|
175
|
-
// Client - pass credentials in the constructor options; connect() authenticates automatically
|
|
176
240
|
const client = new AxioDBCloud("axiodb://localhost:27019", {
|
|
177
241
|
username: 'admin',
|
|
178
242
|
password: 'admin',
|
|
@@ -182,8 +246,7 @@ await client.connect();
|
|
|
182
246
|
console.log(client.authenticatedUser); // { username, role, mustChangePassword }
|
|
183
247
|
```
|
|
184
248
|
|
|
185
|
-
|
|
186
|
-
|
|
249
|
+
**Client โ authenticate after connecting** (e.g. credentials supplied at runtime):
|
|
187
250
|
```javascript
|
|
188
251
|
const client = new AxioDBCloud("axiodb://localhost:27019");
|
|
189
252
|
await client.connect();
|
|
@@ -193,202 +256,181 @@ await client.login('admin', 'admin');
|
|
|
193
256
|
**What's enforced:**
|
|
194
257
|
- Every command except `PING`/`DISCONNECT`/`AUTHENTICATE` requires a prior successful login on that connection.
|
|
195
258
|
- The same role permissions as the GUI apply per command (e.g. a `View`-role user gets `403` on `CREATE_DB`).
|
|
196
|
-
-
|
|
197
|
-
- **Accounts that still need their forced password change are rejected outright
|
|
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.
|
|
198
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.
|
|
199
262
|
|
|
200
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.
|
|
201
264
|
|
|
202
|
-
|
|
265
|
+
๐ **[Full AxioDBCloud Documentation](https://axiodb.in/cloud)** โ setup guides, API reference, Docker examples
|
|
203
266
|
|
|
204
|
-
|
|
205
|
-
โ
**Optional Authentication (NEW!)** - Shared RBAC with the GUI, per-IP rate limiting, forced-password-change enforcement
|
|
206
|
-
โ
**Auto-Reconnect** - Exponential backoff with up to 10 retry attempts
|
|
207
|
-
โ
**Heartbeat Monitoring** - PING/PONG every 30 seconds
|
|
208
|
-
โ
**Request Correlation** - UUID-based request/response matching
|
|
209
|
-
โ
**Connection Pooling** - Supports 1000+ concurrent connections
|
|
210
|
-
โ
**TypeScript Support** - Full type definitions included
|
|
211
|
-
โ
**Zero Breaking Changes** - Existing AxioDB code works unchanged
|
|
267
|
+
---
|
|
212
268
|
|
|
213
|
-
|
|
269
|
+
## ๐ง Troubleshooting
|
|
214
270
|
|
|
215
|
-
|
|
216
|
-
- **Desktop Apps:** Electron apps connecting to local/remote database
|
|
217
|
-
- **Development:** Team members sharing a development database
|
|
218
|
-
- **Docker Deployments:** Container-based production deployments
|
|
219
|
-
- **Cloud Hosting:** Deploy to AWS, Azure, Google Cloud, DigitalOcean
|
|
271
|
+
### "Not connected to server" right after calling `connect()`
|
|
220
272
|
|
|
221
|
-
|
|
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.
|
|
222
274
|
|
|
223
|
-
|
|
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"
|
|
224
280
|
|
|
225
|
-
|
|
281
|
+
// โ
Right
|
|
282
|
+
await client.connect();
|
|
283
|
+
console.log(client.authenticatedUser); // populated
|
|
284
|
+
await client.createDB("MyDB"); // works
|
|
285
|
+
```
|
|
226
286
|
|
|
227
|
-
###
|
|
287
|
+
### `401` โ "Authentication required..."
|
|
228
288
|
|
|
229
|
-
|
|
230
|
-
| ------- | ------ | ------ |
|
|
231
|
-
| **Native Dependencies** | โ Yes (C bindings) | โ
Pure JavaScript |
|
|
232
|
-
| **Query Language** | SQL Strings | JavaScript Objects |
|
|
233
|
-
| **Schema Migrations** | โ Required (ALTER TABLE) | โ
Schema-less (optional) |
|
|
234
|
-
| **Built-in Caching** | โ ๏ธ Manual | โ
InMemoryCache |
|
|
235
|
-
| **Multi-core Processing** | โ Single-threaded | โ
Worker Threads |
|
|
236
|
-
| **Built-in GUI** | โ External tools only | โ
Web interface included |
|
|
237
|
-
| **Best For** | 10M+ records, relational data | 10K-500K documents, embedded apps |
|
|
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.
|
|
238
290
|
|
|
239
|
-
###
|
|
291
|
+
### `403` โ "This account must change its password before it can be used over TCP..."
|
|
240
292
|
|
|
241
|
-
|
|
242
|
-
| ------- | --------------------- | ------ |
|
|
243
|
-
| **Storage** | Single JSON file | File-per-document |
|
|
244
|
-
| **Caching** | None | InMemoryCache |
|
|
245
|
-
| **Indexing** | None | Auto documentId |
|
|
246
|
-
| **Query Speed** | Linear O(n) | Sub-millisecond O(1) |
|
|
247
|
-
| **Scalability** | Poor | Excellent |
|
|
248
|
-
| **Built-in Query Operators** | None | $gt, $lt, $regex, $in |
|
|
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.
|
|
249
294
|
|
|
250
|
-
|
|
295
|
+
### `429` โ "Too many failed login attempts..."
|
|
251
296
|
|
|
252
|
-
|
|
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.
|
|
253
298
|
|
|
254
|
-
|
|
299
|
+
### `403` โ "This is a reserved system database"
|
|
255
300
|
|
|
256
|
-
|
|
257
|
-
- **Secure Storage:** Data stored in `.axiodb` files with file-level isolation and locking
|
|
258
|
-
- **InMemoryCache:** Minimizes disk reads and exposure of sensitive data
|
|
259
|
-
- **Configurable Access Controls:** Protects against unauthorized access
|
|
260
|
-
- **Automatic Cache Invalidation:** Ensures stale data is never served
|
|
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.
|
|
261
302
|
|
|
262
|
-
|
|
303
|
+
### Connection refused / timeout connecting to `axiodb://host:27019`
|
|
263
304
|
|
|
264
|
-
-
|
|
265
|
-
-
|
|
266
|
-
-
|
|
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.
|
|
267
308
|
|
|
268
|
-
|
|
309
|
+
### Docker container issues (won't start, port conflicts, data not persisting)
|
|
269
310
|
|
|
270
|
-
|
|
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).
|
|
271
312
|
|
|
272
|
-
|
|
313
|
+
---
|
|
273
314
|
|
|
274
|
-
|
|
315
|
+
## ๐ณ Docker Deployment
|
|
275
316
|
|
|
276
|
-
###
|
|
317
|
+
### Simple: run the container
|
|
277
318
|
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
|
|
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
|
|
281
327
|
|
|
282
|
-
|
|
283
|
-
|
|
328
|
+
# Ports:
|
|
329
|
+
# 27018 - HTTP GUI Dashboard
|
|
330
|
+
# 27019 - TCP Remote Access (AxioDBCloud)
|
|
331
|
+
# Volume: /app is the main data directory
|
|
284
332
|
```
|
|
285
333
|
|
|
286
|
-
|
|
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).
|
|
287
335
|
|
|
288
|
-
|
|
289
|
-
- ๐ Real-time data inspection
|
|
290
|
-
- ๐ Query execution interface
|
|
291
|
-
- ๐ Performance monitoring
|
|
292
|
-
- ๐ฏ No external dependencies required
|
|
336
|
+
### Advanced: env vars, volumes, Compose
|
|
293
337
|
|
|
294
|
-
|
|
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:
|
|
295
339
|
|
|
296
|
-
|
|
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 |
|
|
297
347
|
|
|
298
|
-
|
|
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`.
|
|
299
349
|
|
|
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
|
|
300
359
|
```
|
|
301
|
-
Username: admin
|
|
302
|
-
Password: admin
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
You'll be forced to change this password on first login (this applies to every account, not just the default one). Three predefined roles are seeded automatically:
|
|
306
|
-
|
|
307
|
-
| Role | Access |
|
|
308
|
-
|------|--------|
|
|
309
|
-
| **Super Admin** | Full access, including creating users/roles |
|
|
310
|
-
| **Admin** | Full database/collection/document access, no user or role management |
|
|
311
|
-
| **View** | Read-only access to databases, collections, and documents |
|
|
312
|
-
|
|
313
|
-
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.
|
|
314
360
|
|
|
315
|
-
**
|
|
316
|
-
|
|
317
|
-
|
|
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
|
+
```
|
|
318
384
|
|
|
319
|
-
|
|
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.
|
|
320
386
|
|
|
321
387
|
---
|
|
322
388
|
|
|
323
|
-
##
|
|
324
|
-
|
|
325
|
-
### Tree Structure for Fast Data Retrieval
|
|
326
|
-
|
|
327
|
-
Hierarchical storage enables O(1) document lookups, logarithmic query time, and efficient indexing. Each document is isolated in its own file, supporting selective loading and easy backup.
|
|
328
|
-
|
|
329
|
-
### Worker Threads for Parallel Processing
|
|
330
|
-
|
|
331
|
-
Leverages Node.js Worker Threads for non-blocking I/O, multi-core utilization, and scalable performanceโespecially for read operations.
|
|
332
|
-
|
|
333
|
-
### Two-Pointer Searching Algorithm
|
|
334
|
-
|
|
335
|
-
Optimized for range queries and filtered searches, minimizing memory usage and computational overhead.
|
|
336
|
-
|
|
337
|
-
### InMemoryCache System
|
|
389
|
+
## ๐จ Built-in Web GUI & Authentication (RBAC)
|
|
338
390
|
|
|
339
|
-
|
|
391
|
+
AxioDB includes a built-in web-based GUI for database visualization and management โ perfect for Electron apps and development environments.
|
|
340
392
|
|
|
341
|
-
###
|
|
342
|
-
|
|
343
|
-
Intelligent caching, parallelized processing, lazy evaluation, and just-in-time query optimization for maximum throughput.
|
|
344
|
-
|
|
345
|
-
### Single Instance Architecture
|
|
393
|
+
### Enabling the GUI
|
|
346
394
|
|
|
347
|
-
|
|
395
|
+
```javascript
|
|
396
|
+
// Enable GUI when creating the AxioDB instance
|
|
397
|
+
const db = new AxioDB({ GUI: true }); // GUI available at localhost:27018
|
|
348
398
|
|
|
349
|
-
|
|
399
|
+
// With a custom database path
|
|
400
|
+
const db = new AxioDB({ GUI: true, RootName: "MyDB", CustomPath: "./custom/path" });
|
|
401
|
+
```
|
|
350
402
|
|
|
351
|
-
|
|
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.
|
|
352
404
|
|
|
353
|
-
|
|
405
|
+
### Authentication & Access Control
|
|
354
406
|
|
|
355
|
-
|
|
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:
|
|
356
408
|
|
|
357
|
-
```
|
|
358
|
-
|
|
409
|
+
```
|
|
410
|
+
Username: admin
|
|
411
|
+
Password: admin
|
|
359
412
|
```
|
|
360
413
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
## ๐ ๏ธ Quick Start
|
|
364
|
-
|
|
365
|
-
### 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:
|
|
366
415
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
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 |
|
|
370
421
|
|
|
371
|
-
|
|
372
|
-
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.
|
|
373
423
|
|
|
374
|
-
|
|
375
|
-
const myDB = await db.createDB('HelloWorldDB');
|
|
376
|
-
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).
|
|
377
425
|
|
|
378
|
-
|
|
379
|
-
await collection.insert({ message: 'Hello, Developer! ๐' });
|
|
380
|
-
const result = await collection.findAll();
|
|
381
|
-
console.log(result[0].message); // Hello, Developer! ๐
|
|
382
|
-
```
|
|
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).
|
|
383
427
|
|
|
384
|
-
**
|
|
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.
|
|
385
429
|
|
|
386
430
|
---
|
|
387
431
|
|
|
388
432
|
## ๐ ๏ธ Detailed Usage
|
|
389
433
|
|
|
390
|
-
> **Important:** Only one AxioDB instance should be initialized per application for consistency and security.
|
|
391
|
-
|
|
392
434
|
### Collection Creation Options
|
|
393
435
|
|
|
394
436
|
```javascript
|
|
@@ -407,10 +449,10 @@ const db = new AxioDB();
|
|
|
407
449
|
|
|
408
450
|
const userDB = await db.createDB("MyDB");
|
|
409
451
|
|
|
410
|
-
// Create basic collection
|
|
452
|
+
// Create a basic collection
|
|
411
453
|
const userCollection = await userDB.createCollection("Users");
|
|
412
454
|
|
|
413
|
-
// Create encrypted collection with custom key
|
|
455
|
+
// Create an encrypted collection with a custom key
|
|
414
456
|
const secureCollection = await userDB.createCollection(
|
|
415
457
|
"SecureUsers",
|
|
416
458
|
true,
|
|
@@ -428,24 +470,59 @@ const results = await userCollection
|
|
|
428
470
|
.Limit(10)
|
|
429
471
|
.Sort({ age: 1 })
|
|
430
472
|
.exec();
|
|
431
|
-
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();
|
|
432
516
|
```
|
|
433
517
|
|
|
434
518
|
---
|
|
435
519
|
|
|
436
520
|
## ๐ Advanced Features
|
|
437
521
|
|
|
438
|
-
- **Multiple Databases:**
|
|
439
|
-
- **
|
|
440
|
-
- **
|
|
441
|
-
- **
|
|
442
|
-
- **Flexible Collection Types:** Basic or encrypted
|
|
443
|
-
- **Custom Query Operators:** `$gt`, `$lt`, `$in`, `$regex`, `$gte`, `$lte`, `$ne`, `$nin`, `$exists`, `$or`, `$and`
|
|
444
|
-
- **Schema-less Design:** Store any JSON structure without predefined schemas
|
|
445
|
-
- **Performance Optimization:** Fast lookups, pagination, and intelligent caching with random TTL
|
|
446
|
-
- **ACID Transactions:** Single-collection transactions with savepoints, rollback, and WAL recovery
|
|
447
|
-
- **Index Management:** Create custom indexes, automatic document-to-index sync on CRUD operations
|
|
448
|
-
- **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
|
|
449
526
|
|
|
450
527
|
---
|
|
451
528
|
|
|
@@ -453,7 +530,7 @@ console.log(results);
|
|
|
453
530
|
|
|
454
531
|
### AxioDB
|
|
455
532
|
|
|
456
|
-
- `createDB(dbName: string
|
|
533
|
+
- `createDB(dbName: string): Promise<Database>`
|
|
457
534
|
- `deleteDatabase(dbName: string): Promise<SuccessInterface | ErrorInterface>`
|
|
458
535
|
|
|
459
536
|
### Database
|
|
@@ -473,7 +550,7 @@ console.log(results);
|
|
|
473
550
|
- `startSession(options?: SessionOptions): Session`
|
|
474
551
|
- `newIndex(...fieldNames: string[]): Promise<SuccessInterface>`
|
|
475
552
|
- `dropIndex(indexName: string): Promise<SuccessInterface | ErrorInterface>`
|
|
476
|
-
- `getIndexes(): Promise<SuccessInterface | ErrorInterface>` โ lists all indexes registered on the collection
|
|
553
|
+
- `getIndexes(): Promise<SuccessInterface | ErrorInterface>` โ lists all indexes registered on the collection
|
|
477
554
|
|
|
478
555
|
### Reader
|
|
479
556
|
|
|
@@ -500,45 +577,95 @@ console.log(results);
|
|
|
500
577
|
|
|
501
578
|
---
|
|
502
579
|
|
|
503
|
-
##
|
|
580
|
+
## โ
Best Practices
|
|
504
581
|
|
|
505
|
-
**
|
|
506
|
-
- ๐ฅ๏ธ Desktop apps (Electron, Tauri)
|
|
507
|
-
- ๐ ๏ธ CLI tools
|
|
508
|
-
- ๐ฆ Embedded systems
|
|
509
|
-
- ๐ Rapid prototyping
|
|
510
|
-
- ๐ Local-first applications
|
|
511
|
-
- ๐ป Node.js apps requiring local storage
|
|
582
|
+
**Use environment variables for encryption keys and TCP credentials โ never hardcode them:**
|
|
512
583
|
|
|
513
|
-
|
|
584
|
+
```javascript
|
|
585
|
+
// โ Bad
|
|
586
|
+
const collection = await db.createCollection('data', true, 'myKey123');
|
|
514
587
|
|
|
515
|
-
|
|
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
|
+
```
|
|
516
611
|
|
|
517
|
-
|
|
612
|
+
**Clean up resources you no longer need:**
|
|
613
|
+
|
|
614
|
+
```javascript
|
|
615
|
+
await database.deleteCollection('tempCollection');
|
|
616
|
+
await db.deleteDatabase('tempDB');
|
|
617
|
+
```
|
|
518
618
|
|
|
519
|
-
**
|
|
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))
|
|
520
624
|
|
|
521
|
-
|
|
625
|
+
For vulnerability reporting, see [SECURITY.md](SECURITY.md).
|
|
522
626
|
|
|
523
627
|
---
|
|
524
628
|
|
|
525
|
-
##
|
|
629
|
+
## โ๏ธ Architecture & Internal Mechanisms
|
|
526
630
|
|
|
527
|
-
|
|
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.
|
|
528
638
|
|
|
529
|
-
|
|
639
|
+
---
|
|
530
640
|
|
|
531
|
-
|
|
641
|
+
## ๐ Comparisons
|
|
532
642
|
|
|
533
|
-
|
|
643
|
+
### AxioDB vs SQLite
|
|
534
644
|
|
|
535
|
-
|
|
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 |
|
|
536
654
|
|
|
537
|
-
|
|
655
|
+
### AxioDB vs Traditional JSON Files
|
|
538
656
|
|
|
539
|
-
|
|
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).
|
|
540
667
|
|
|
541
|
-
|
|
668
|
+
### AxioDB vs lowdb, nedb, better-sqlite3
|
|
542
669
|
|
|
543
670
|
| Feature | lowdb | nedb | better-sqlite3 | AxioDB |
|
|
544
671
|
|---------|-------|------|---------------|--------|
|
|
@@ -558,109 +685,71 @@ When you outgrow AxioDB (1M+ documents, distributed systems), migrate to Postgre
|
|
|
558
685
|
|
|
559
686
|
---
|
|
560
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
|
+
|
|
561
700
|
## โ FAQ
|
|
562
701
|
|
|
563
702
|
**Q: What is AxioDB?**
|
|
564
|
-
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`.
|
|
565
704
|
|
|
566
705
|
**Q: Is AxioDB a replacement for MongoDB?**
|
|
567
|
-
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.
|
|
568
707
|
|
|
569
708
|
**Q: Does AxioDB work with Electron?**
|
|
570
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.
|
|
571
710
|
|
|
572
|
-
**Q:
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
**Q: What is the difference between AxioDB and lowdb?**
|
|
576
|
-
`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.
|
|
577
|
-
|
|
578
|
-
**Q: What is the difference between AxioDB and nedb?**
|
|
579
|
-
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).
|
|
580
713
|
|
|
581
714
|
**Q: How many documents can AxioDB handle?**
|
|
582
|
-
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`.
|
|
583
716
|
|
|
584
717
|
**Q: Does AxioDB support TypeScript?**
|
|
585
718
|
Yes. Full type definitions are included โ no separate `@types` package needed.
|
|
586
719
|
|
|
587
720
|
**Q: Does AxioDB work in the browser?**
|
|
588
|
-
No. AxioDB requires Node.js (v20+) and the filesystem
|
|
721
|
+
No. AxioDB requires Node.js (v20+) and the filesystem โ server-side and desktop only.
|
|
589
722
|
|
|
590
723
|
**Q: What is AxioDBCloud?**
|
|
591
|
-
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.
|
|
592
|
-
|
|
593
|
-
---
|
|
594
|
-
|
|
595
|
-
## ๐ฎ Future Roadmap
|
|
596
|
-
|
|
597
|
-
- **Data Export & Import:** Seamless data migration with support for JSON, CSV, and native AxioDB formats
|
|
598
|
-
- **Enhanced Web GUI:** Advanced web interface with real-time analytics, visual query builder, and performance monitoring
|
|
599
|
-
- **Comprehensive Documentation:** Extensive tutorials, interactive examples, and complete API references for all skill levels
|
|
600
|
-
- **Performance Optimizations:** Continued improvements to query performance and caching strategies
|
|
601
|
-
|
|
602
|
-
---
|
|
603
|
-
|
|
604
|
-
## ๐ค Contributing
|
|
605
|
-
|
|
606
|
-
We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
607
|
-
|
|
608
|
-
---
|
|
609
|
-
|
|
610
|
-
## ๐ License
|
|
611
|
-
|
|
612
|
-
MIT License. See [LICENSE](LICENSE).
|
|
613
|
-
|
|
614
|
-
---
|
|
615
|
-
|
|
616
|
-
## ๐ Acknowledgments
|
|
617
|
-
|
|
618
|
-
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.
|
|
619
725
|
|
|
620
726
|
---
|
|
621
727
|
|
|
622
|
-
##
|
|
623
|
-
|
|
624
|
-
- **Node.js:** >=20.0.0
|
|
625
|
-
- **npm:** >=6.0.0
|
|
626
|
-
- **yarn:** >=1.0.0 (optional)
|
|
627
|
-
|
|
628
|
-
---
|
|
728
|
+
## ๐ค Contributing, License & Support
|
|
629
729
|
|
|
630
|
-
|
|
730
|
+
**Contributing:** we welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
631
731
|
|
|
632
|
-
|
|
633
|
-
- **React 18** with TypeScript
|
|
634
|
-
- **Vite** for fast development and building
|
|
635
|
-
- **TailwindCSS** for styling
|
|
636
|
-
- **Lucide React** for icons
|
|
732
|
+
**License:** MIT. See [LICENSE](LICENSE).
|
|
637
733
|
|
|
638
|
-
|
|
734
|
+
**Requirements:** Node.js โฅ20.0.0, npm โฅ6.0.0, yarn โฅ1.0.0 (optional).
|
|
639
735
|
|
|
736
|
+
**Documentation website:** built with React 18 + TypeScript, Vite, TailwindCSS, and Lucide React. To run it locally:
|
|
640
737
|
```bash
|
|
641
738
|
cd Document
|
|
642
739
|
npm install
|
|
643
740
|
npm run dev
|
|
644
741
|
```
|
|
742
|
+
Available at `http://localhost:5173`.
|
|
645
743
|
|
|
646
|
-
|
|
744
|
+
**Author:** Ankan Saha
|
|
647
745
|
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
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)
|
|
651
752
|
|
|
652
|
-
**
|
|
753
|
+
**Acknowledgments:** special thanks to all contributors and supporters of AxioDB โ your feedback and contributions make this project better.
|
|
653
754
|
|
|
654
755
|
---
|
|
655
|
-
|
|
656
|
-
## ๐ Support
|
|
657
|
-
|
|
658
|
-
If you find AxioDB helpful, consider:
|
|
659
|
-
- โญ Starring the repository
|
|
660
|
-
- ๐ Reporting issues
|
|
661
|
-
- ๐ก Suggesting features
|
|
662
|
-
- ๐ค Contributing code
|
|
663
|
-
- ๐ฐ [Sponsoring the project](https://github.com/sponsors/AnkanSaha)
|
|
664
|
-
|
|
665
|
-
---
|
|
666
|
-
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "axiodb",
|
|
3
|
-
"version": "11.9.
|
|
3
|
+
"version": "11.9.13",
|
|
4
4
|
"description": "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 platform issuesโpure JavaScript from npm install to production.",
|
|
5
5
|
"main": "./lib/config/DB.js",
|
|
6
6
|
"types": "./lib/config/DB.d.ts",
|