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

javascript
1const { AxioDB } = require("axiodb");
2
3// Create a single AxioDB instance for your entire application
4// Enable GUI (most common): localhost:27018
5const Instance = new AxioDB({ GUI: true });
6
7// Other constructor options:
8const NoGUIInstance = new AxioDB({ GUI: false }); // Disable GUI
9const CustomNameInstance = new AxioDB({ GUI: true, RootName: "MyCustomDB" }); // Custom database name
10const CustomPathInstance = new AxioDB({ GUI: true, RootName: "MyDB", CustomPath: "./data" }); // Custom path
11
12const main = async () => {
13 // Create database
14 const UserDB = await Instance.createDB("MyDB");
15
16 // Create different types of collections
17 const UserCollection = await UserDB.createCollection("Users"); // Basic collection
18 const CollectionWithCrypto = await UserDB.createCollection("UsersWithCrypto", true); // With auto-generated key
19 const CollectionWithCryptoKey = await UserDB.createCollection("UsersWithCryptoKey", true, "secretKey123"); // With custom key
20
21 // Insert single document - no schema required, store any JSON
22 await UserCollection.insert({
23 name: "John Doe",
24 email: "[email protected]",
25 age: 30
26 });
27
28 // Insert multiple documents
29 await UserCollection.insertMany([
30 {
31 name: "Jane Doe",
32 email: "[email protected]",
33 age: 25
34 },
35 {
36 name: "Alice Smith",
37 email: "[email protected]",
38 age: 28
39 }
40 ]);
41
42 // Query with different operators
43 const olderUsers = await UserCollection.query({
44 age: { $gt: 25 }
45 }).exec();
46
47 // Regex query
48 const exampleUsers = await UserCollection.query({
49 email: { $regex: /example.com$/ }
50 }).exec();
51
52 // Complex query with chaining
53 const results = await UserCollection.query({
54 email: { $in: ["[email protected]", "[email protected]"] }
55 }).Limit(10).Skip(2).Sort({ age: 1 }).findOne(true).setCount(true).setProject({
56 _id: 1,
57 name: 1,
58 email: 1
59 }).exec();
60
61 // Fast retrieval by documentId
62 const fastRes = await UserCollection.query({ documentId: "JOHTAOIJNHUJOBD" }).exec();
63
64 // Aggregation pipeline
65 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 operations
80 await UserCollection.update({ name: "John Doe" }).UpdateOne({ name: "Ankan" });
81 await UserCollection.update({ name: "John Doe" }).UpdateMany({ name: "Ankan" });
82
83 // Delete operations
84 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

javascript
1import { AxioDB } from "axiodb";
2
3// Create a single AxioDB instance for your entire application
4// Enable GUI (most common): localhost:27018
5const Instance = new AxioDB({ GUI: true });
6
7// Other constructor options:
8const NoGUIInstance = new AxioDB({ GUI: false }); // Disable GUI
9const CustomNameInstance = new AxioDB({ GUI: true, RootName: "MyCustomDB" }); // Custom database name
10const CustomPathInstance = new AxioDB({ GUI: true, RootName: "MyDB", CustomPath: "./data" }); // Custom path
11
12const main = async () => {
13 // Create database
14 const UserDB = await Instance.createDB("MyDB");
15
16 // Create different types of collections
17 const UserCollection = await UserDB.createCollection("Users"); // Basic collection
18 const CollectionWithCrypto = await UserDB.createCollection("UsersWithCrypto", true); // With auto-generated key
19 const CollectionWithCryptoKey = await UserDB.createCollection("UsersWithCryptoKey", true, "secretKey123"); // With custom key
20
21 // Insert single document - no schema required, store any JSON
22 await UserCollection.insert({
23 name: "John Doe",
24 email: "[email protected]",
25 age: 30
26 });
27
28 // Insert multiple documents
29 await UserCollection.insertMany([
30 {
31 name: "Jane Doe",
32 email: "[email protected]",
33 age: 25
34 },
35 {
36 name: "Alice Smith",
37 email: "[email protected]",
38 age: 28
39 }
40 ]);
41
42 // Query with different operators
43 const olderUsers = await UserCollection.query({
44 age: { $gt: 25 }
45 }).exec();
46
47 // Regex query
48 const exampleUsers = await UserCollection.query({
49 email: { $regex: /example.com$/ }
50 }).exec();
51
52 // Complex query with chaining
53 const results = await UserCollection.query({
54 email: { $in: ["[email protected]", "[email protected]"] }
55 }).Limit(10).Skip(2).Sort({ age: 1 }).findOne(true).setCount(true).setProject({
56 _id: 1,
57 name: 1,
58 email: 1
59 }).exec();
60
61 // Fast retrieval by documentId
62 const fastRes = await UserCollection.query({ documentId: "JOHTAOIJNHUJOBD"}).exec();
63
64 // Aggregation pipeline
65 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 operations
80 await UserCollection.update({name: "John Doe"}).UpdateOne({name: "Ankan"});
81 await UserCollection.update({name: "John Doe"}).UpdateMany({name: "Ankan"});
82
83 // Delete operations
84 await UserCollection.delete({name: "John Doe"}).DeleteOne();
85 await UserCollection.delete({name: "John Doe"}).DeleteMany();
86};
87
88main();