Getting Started with AxioDB
Interactive examples and comprehensive usage guide
Explore AxioDB's powerful features through interactive examples. From basic CRUD operations to advanced aggregation pipelines, master every aspect of modern NoSQL database operations with our comprehensive, production-ready code samples.
Instance Management Architecture
AxioDB employs a single instance architecture for optimal data consistency and security. Initialize one AxioDB instance with the new keyword, enabling unlimited databases, collections, and documents under unified management.
Upon instance creation, AxioDB automatically launches a comprehensive web-based management interface at localhost:27018 for visual database administration and real-time monitoring.
Interactive Code Examples
Explore different operations with live code samples
Choose your preferred module system to get started:
Complete CommonJS Implementation
Production-ready example with all major features
1const { AxioDB } = require("axiodb");2
3// Create a single AxioDB instance for your entire application4// Enable GUI (most common): localhost:270185const Instance = new AxioDB({ GUI: true });6
7// Other constructor options:8const NoGUIInstance = new AxioDB({ GUI: false }); // Disable GUI9const CustomNameInstance = new AxioDB({ GUI: true, RootName: "MyCustomDB" }); // Custom database name10const CustomPathInstance = new AxioDB({ GUI: true, RootName: "MyDB", CustomPath: "./data" }); // Custom path11
12const main = async () => {13 // Create database14 const UserDB = await Instance.createDB("MyDB");15
16 // Create different types of collections17 const UserCollection = await UserDB.createCollection("Users"); // Basic collection18 const CollectionWithCrypto = await UserDB.createCollection("UsersWithCrypto", true); // With auto-generated key19 const CollectionWithCryptoKey = await UserDB.createCollection("UsersWithCryptoKey", true, "secretKey123"); // With custom key20
21 // Insert single document - no schema required, store any JSON22 await UserCollection.insert({23 name: "John Doe",25 age: 3026 });27
28 // Insert multiple documents29 await UserCollection.insertMany([30 {31 name: "Jane Doe",33 age: 2534 },35 {36 name: "Alice Smith",38 age: 2839 }40 ]);41
42 // Query with different operators43 const olderUsers = await UserCollection.query({44 age: { $gt: 25 }45 }).exec();46
47 // Regex query48 const exampleUsers = await UserCollection.query({49 email: { $regex: /example.com$/ }50 }).exec();51
52 // Complex query with chaining53 const results = await UserCollection.query({55 }).Limit(10).Skip(2).Sort({ age: 1 }).findOne(true).setCount(true).setProject({56 _id: 1,57 name: 1,58 email: 159 }).exec();60
61 // Fast retrieval by documentId62 const fastRes = await UserCollection.query({ documentId: "JOHTAOIJNHUJOBD" }).exec();63
64 // Aggregation pipeline65 const aggData = await UserCollection.aggregate([66 {67 $match: {68 age: { $gt: 25 }69 }70 },71 {72 $group: {73 _id: "$email",74 avgAge: { $avg: "$age" }75 }76 }77 ]).exec();78
79 // Update operations80 await UserCollection.update({ name: "John Doe" }).UpdateOne({ name: "Ankan" });81 await UserCollection.update({ name: "John Doe" }).UpdateMany({ name: "Ankan" });82
83 // Delete operations84 await UserCollection.delete({ name: "John Doe" }).DeleteOne();85 await UserCollection.delete({ name: "John Doe" }).DeleteMany();86};87
88main();Complete ES6 Module Implementation
Modern JavaScript with import/export syntax
1import { AxioDB } from "axiodb";2
3// Create a single AxioDB instance for your entire application4// Enable GUI (most common): localhost:270185const Instance = new AxioDB({ GUI: true });6
7// Other constructor options:8const NoGUIInstance = new AxioDB({ GUI: false }); // Disable GUI9const CustomNameInstance = new AxioDB({ GUI: true, RootName: "MyCustomDB" }); // Custom database name10const CustomPathInstance = new AxioDB({ GUI: true, RootName: "MyDB", CustomPath: "./data" }); // Custom path11
12const main = async () => {13 // Create database14 const UserDB = await Instance.createDB("MyDB");15
16 // Create different types of collections17 const UserCollection = await UserDB.createCollection("Users"); // Basic collection18 const CollectionWithCrypto = await UserDB.createCollection("UsersWithCrypto", true); // With auto-generated key19 const CollectionWithCryptoKey = await UserDB.createCollection("UsersWithCryptoKey", true, "secretKey123"); // With custom key20
21 // Insert single document - no schema required, store any JSON22 await UserCollection.insert({23 name: "John Doe",25 age: 3026 });27
28 // Insert multiple documents29 await UserCollection.insertMany([30 {31 name: "Jane Doe",33 age: 2534 },35 {36 name: "Alice Smith",38 age: 2839 }40 ]);41
42 // Query with different operators43 const olderUsers = await UserCollection.query({44 age: { $gt: 25 }45 }).exec();46
47 // Regex query48 const exampleUsers = await UserCollection.query({49 email: { $regex: /example.com$/ }50 }).exec();51
52 // Complex query with chaining53 const results = await UserCollection.query({55 }).Limit(10).Skip(2).Sort({ age: 1 }).findOne(true).setCount(true).setProject({56 _id: 1,57 name: 1,58 email: 159 }).exec();60
61 // Fast retrieval by documentId62 const fastRes = await UserCollection.query({ documentId: "JOHTAOIJNHUJOBD"}).exec();63
64 // Aggregation pipeline65 const aggData = await UserCollection.aggregate([66 {67 $match: {68 age: { $gt: 25 }69 }70 },71 {72 $group: {73 _id: "$email",74 avgAge: { $avg: "$age" }75 }76 }77 ]);78
79 // Update operations80 await UserCollection.update({name: "John Doe"}).UpdateOne({name: "Ankan"});81 await UserCollection.update({name: "John Doe"}).UpdateMany({name: "Ankan"});82
83 // Delete operations84 await UserCollection.delete({name: "John Doe"}).DeleteOne();85 await UserCollection.delete({name: "John Doe"}).DeleteMany();86};87
88main();