Create Database
AxioDB constructor follows the pattern: new AxioDB(options) where options is an object with {GUI?, RootName?, CustomPath?, TCP?}. This pattern provides better readability and flexibility.
💡 Constructor Parameters
- GUI (boolean, optional): Enable web GUI on localhost:27018 - defaults to false
- RootName (string, optional): Custom root folder name - defaults to "AxioDB"
- CustomPath (string, optional): Custom storage path - defaults to current directory
Basic Instance (With GUI)
Most common use case - enable the built-in GUI for data inspection.
javascript
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.
javascript
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.
javascript
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.
javascript
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");Create Multiple Databases
Create multiple isolated databases within your AxioDB instance.
javascript
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
