Create Database
AxioDB constructor follows the pattern: new AxioDB(options) where options is an object with {GUI?, HTTP?, RootName?, CustomPath?, TCP?, TCPAuth?, AdminPassword?, TLS?, TLSCertPath?, TLSKeyPath?, Cache?, minTTL?, maxTTL?, cacheClearUp?}. This pattern provides better readability and flexibility.
💡 Constructor Parameters
- GUI (boolean, optional): Enable web GUI on localhost:27018 - defaults to false
- HTTP (boolean, optional): Enable HTTP API server on port 27018 - auto-enables when GUI is on; GUI: true + HTTP: false throws error
- RootName (string, optional): Custom root folder name - defaults to "AxioDB"
- CustomPath (string, optional): Custom storage path - defaults to current directory
- TCP (boolean, optional): Enable the AxioDBCloud TCP server on port 27019 - defaults to false
- TCPAuth (boolean, optional): Require username/password authentication (same RBAC users as the GUI) on TCP connections - defaults to false
- AdminPassword (string, optional): Password the admin account is seeded with on first start, skipping the forced first-login change - defaults to the built-in admin/admin
- TLS (boolean, optional): Encrypt the TCP server with TLS - requires TLSCertPath + TLSKeyPath PEM files - defaults to false
- Cache (boolean, optional): Enable the per-instance InMemoryCache - defaults to true (set false to disable caching entirely)
- minTTL (number, optional): Minimum randomized cache TTL in minutes - defaults to 5
- maxTTL (number, optional): Maximum randomized cache TTL in minutes - defaults to 15
- cacheClearUp (number, optional): Cache cleanup sweep interval in seconds - defaults to 86400
Setting the Admin Password (No GUI)
On first start AxioDB seeds an admin/admin account and flags it mustChangePassword: true. The forced change can only be completed through the HTTP API or the GUI - so if you start the server with GUI: false and TCPAuth: true, there would be no way to choose a password and TCP would reject every login. Pass AdminPassword to seed the account ready to use instead.
1const db = new AxioDB({2 TCP: true,3 TCPAuth: true,4 GUI: false,5 AdminPassword: 'my-secret-password',6});7
8// admin / my-secret-password can log in over TCP immediately- One account, every surface. Embedded, HTTP, GUI, TCP and MCP all read the same
configdatabase, so this password is the same everywhere. - First start only. The value is read solely when the
userscollection is created. Once your data directory exists, restarting never resets a password you have since changed. - Opt-in. Omit it and the default
admin/admin+ forced change behaviour is exactly as before - no breaking change. - Same option in the CLI and Docker.
axiodb serve tcp-auth <password>and theAXIODB_ADMIN_PASSWORDenvironment variable both map to it.
Basic Instance (With GUI)
Most common use case - enable the built-in GUI for data inspection.
1
2const { AxioDB } = require("axiodb");3
4// Create AxioDB instance with GUI enabled (most common)5const db = new AxioDB({ GUI: true });6console.log("AxioDB instance created with GUI at localhost:27018");Instance Without GUI
For production environments where you don't need the web interface.
1
2// Create AxioDB instance without GUI3const db = new AxioDB({ GUI: false });4console.log("AxioDB instance created without GUI");Custom Database Name
Specify a custom root folder name for your database.
1
2// Create AxioDB instance with GUI and custom root folder name3const db = new AxioDB({ GUI: true, RootName: "MyCustomDB" });4console.log("Custom AxioDB instance created with GUI");Custom Storage Path
Store database files in a specific directory.
1
2// Create AxioDB instance with GUI, custom name, and custom path3const db = new AxioDB({ GUI: true, RootName: "MyCustomDB", CustomPath: "./data" });4console.log("AxioDB instance with custom path created");TCP Server with Authentication
Enable remote access via AxioDBCloud and require login before any TCP command is accepted.
1
2// Create AxioDB instance with the TCP server enabled and authentication required3const db = new AxioDB({ TCP: true, TCPAuth: true, RootName: "MyCustomDB", CustomPath: "./data" });4console.log("AxioDB instance with authenticated TCP access created");Cache Tuning
Each instance owns an InMemoryCache. Tune its randomized TTL bounds and cleanup interval, or disable it entirely with Cache: false.
1
2// Tune the per-instance InMemoryCache: 10-30 minute randomized TTL, hourly cleanup3const db = new AxioDB({ Cache: true, minTTL: 10, maxTTL: 30, cacheClearUp: 3600 });4
5// Disable caching entirely (reads always hit disk)6const dbNoCache = new AxioDB({ Cache: false });Create Multiple Databases
Create multiple isolated databases within your AxioDB instance.
1
2// Create databases under the current AxioDB instance3const userDB = await db.createDB("UsersDB");4console.log("Database 'UsersDB' created");5
6const productsDB = await db.createDB("ProductsDB");7console.log("Database 'ProductsDB' created");⚠️ Important Notes
- Only one AxioDB instance is allowed per application (singleton pattern)
- GUI runs on localhost:27018 and starts automatically when enabled
- Database files are stored in the root folder you specify
- Each database can contain multiple collections
See also: Create Collection · Usage
