axiodb 1.7.5 → 1.7.9

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 CHANGED
@@ -84,31 +84,176 @@ npm install axiodb@latest --save
84
84
  ```javascript
85
85
  const { AxioDB, SchemaTypes } = require("axiodb");
86
86
 
87
- // Initialize AxioDB
88
- const db = new AxioDB();
87
+ const main = async () => {
88
+ const db = new AxioDB();
89
+
90
+ // Create a database
91
+ const db1 = await db.createDB("testDB");
92
+
93
+ // Define a schema
94
+ const schema = {
95
+ name: SchemaTypes.string().required(),
96
+ age: SchemaTypes.number().required().min(1).max(100),
97
+ email: SchemaTypes.string().required().email(),
98
+ };
99
+
100
+ // Create collections
101
+ const collection = await db1.createCollection("testCollection", schema);
102
+ const collection2 = await db1.createCollection(
103
+ "testCollection2",
104
+ schema,
105
+ true,
106
+ );
107
+ const collection3 = await db1.createCollection(
108
+ "testCollection3",
109
+ schema,
110
+ "myKey",
111
+ );
112
+
113
+ // Insert data
114
+ const saveStatus = await collection.insert({
115
+ name: "Ankan",
116
+ age: 21,
117
+ email: "ankan@example.com",
118
+ });
119
+ console.log(saveStatus);
120
+
121
+ // Query data
122
+ const totalDocuments = await collection
123
+ .query({})
124
+ .Limit(1)
125
+ .Skip(0)
126
+ .Sort({ name: 1 })
127
+ .setCount(true)
128
+ .setProject({ name: 1, age: 1 })
129
+ .exec();
130
+ console.log(totalDocuments);
131
+
132
+ const FastDocument = await collection
133
+ .query({ documentId: "S4ACDVS6SZ4S6VS" })
134
+ .exec(); // By using documentId you can get the document in Lightning Fast Speed, no matter how many documents are in the collection (Tested with 1000000+ documents)
135
+ console.log(FastDocument);
136
+
137
+ const ArrayFirstDocument = await collection
138
+ .query({ documentId: ["S4ACDVS6SZ4S6VS", "VESV61Z6VS16VSE6V1S"] })
139
+ .exec(); // query using an array of documentId to get multiple documents in lightning fast speed, no matter how many documents are in the collection (Tested with 1000000+ documents)
140
+ console.log(ArrayFirstDocument);
141
+
142
+ // Update data
143
+ const updatedDocuments = await collection
144
+ .update({ name: { $regex: "Ankan" } })
145
+ .UpdateOne({ name: "Ankan Saha", age: 22 });
146
+ console.log(updatedDocuments);
147
+
148
+ // Delete data
149
+ const deletedDocuments = await collection
150
+ .delete({ name: { $regex: "Ankan" } })
151
+ .deleteOne();
152
+ console.log(deletedDocuments);
153
+
154
+ // Aggregation
155
+ const response = await collection
156
+ .aggregate([
157
+ { $match: { age: { $gt: 20 }, name: { $regex: "Ankan" } } },
158
+ { $group: { _id: "$age", count: { $sum: 1 } } },
159
+ { $sort: { count: -1 } },
160
+ { $project: { _id: 0, age: "$_id", count: 1 } },
161
+ { $limit: 10 },
162
+ { $skip: 0 },
163
+ ])
164
+ .exec();
165
+ console.log(response);
166
+ };
167
+
168
+ main();
169
+ ```
170
+
171
+ ---
172
+
173
+ ### ES6 Example
174
+
175
+ ```javascript
176
+ import { AxioDB, SchemaTypes } from "axiodb";
89
177
 
90
178
  const main = async () => {
179
+ const db = new AxioDB();
180
+
91
181
  // Create a database
92
- const database = await db.createDB("myDatabase");
182
+ const db1 = await db.createDB("testDB");
93
183
 
94
184
  // Define a schema
95
- const userSchema = {
185
+ const schema = {
96
186
  name: SchemaTypes.string().required(),
97
- age: SchemaTypes.number().required(),
187
+ age: SchemaTypes.number().required().min(1).max(100),
188
+ email: SchemaTypes.string().required().email(),
98
189
  };
99
190
 
100
- // Create a collection with schema
101
- const users = await database.createCollection("users", userSchema);
191
+ // Create collections
192
+ const collection = await db1.createCollection("testCollection", schema);
193
+ const collection2 = await db1.createCollection(
194
+ "testCollection2",
195
+ schema,
196
+ true,
197
+ );
198
+ const collection3 = await db1.createCollection(
199
+ "testCollection3",
200
+ schema,
201
+ "myKey",
202
+ );
102
203
 
103
204
  // Insert data
104
- await users.insert({ name: "John Doe", age: 30 });
205
+ const saveStatus = await collection.insert({
206
+ name: "Ankan",
207
+ age: 21,
208
+ email: "ankan@example.com",
209
+ });
210
+ console.log(saveStatus);
105
211
 
106
212
  // Query data
107
- const result = await users
108
- .query({ age: { $gt: 25 } })
109
- .Limit(10)
213
+ const totalDocuments = await collection
214
+ .query({})
215
+ .Limit(1)
216
+ .Skip(0)
217
+ .Sort({ name: 1 })
218
+ .setCount(true)
219
+ .setProject({ name: 1, age: 1 })
220
+ .exec();
221
+ console.log(totalDocuments);
222
+
223
+ const FastDocument = await collection
224
+ .query({ documentId: "S4ACDVS6SZ4S6VS" })
225
+ .exec(); // By using documentId you can get the document in Lightning Fast Speed, no matter how many documents are in the collection (Tested with 1000000+ documents)
226
+ console.log(FastDocument);
227
+
228
+ const ArrayFirstDocument = await collection
229
+ .query({ documentId: ["S4ACDVS6SZ4S6VS", "VESV61Z6VS16VSE6V1S"] })
230
+ .exec(); // query using an array of documentId to get multiple documents in lightning fast speed, no matter how many documents are in the collection (Tested with 1000000+ documents)
231
+ console.log(ArrayFirstDocument);
232
+
233
+ // Update data
234
+ const updatedDocuments = await collection
235
+ .update({ name: { $regex: "Ankan" } })
236
+ .UpdateOne({ name: "Ankan Saha", age: 22 });
237
+ console.log(updatedDocuments);
238
+
239
+ // Delete data
240
+ const deletedDocuments = await collection
241
+ .delete({ name: { $regex: "Ankan" } })
242
+ .deleteOne();
243
+ console.log(deletedDocuments);
244
+
245
+ // Aggregation
246
+ const response = await collection
247
+ .aggregate([
248
+ { $match: { age: { $gt: 20 }, name: { $regex: "Ankan" } } },
249
+ { $group: { _id: "$age", count: { $sum: 1 } } },
250
+ { $sort: { count: -1 } },
251
+ { $project: { _id: 0, age: "$_id", count: 1 } },
252
+ { $limit: 10 },
253
+ { $skip: 0 },
254
+ ])
110
255
  .exec();
111
- console.log("Query Result:", result);
256
+ console.log(response);
112
257
  };
113
258
 
114
259
  main();
@@ -3,5 +3,9 @@ export declare enum General {
3
3
  DBMS_File_EXT = ".axiodb"
4
4
  }
5
5
  export declare enum WebServer {
6
- ServerPORT = 2025
6
+ StaticServerPORT = 2025,
7
+ ApiServerPORT = 2026,
8
+ TCPServerPORT = 2027,
9
+ WebSocketServerPORT = 2028,
10
+ GraphQLServerPORT = 2029
7
11
  }
@@ -9,6 +9,10 @@ var General;
9
9
  // Web Server Configuration
10
10
  var WebServer;
11
11
  (function (WebServer) {
12
- WebServer[WebServer["ServerPORT"] = 2025] = "ServerPORT";
12
+ WebServer[WebServer["StaticServerPORT"] = 2025] = "StaticServerPORT";
13
+ WebServer[WebServer["ApiServerPORT"] = 2026] = "ApiServerPORT";
14
+ WebServer[WebServer["TCPServerPORT"] = 2027] = "TCPServerPORT";
15
+ WebServer[WebServer["WebSocketServerPORT"] = 2028] = "WebSocketServerPORT";
16
+ WebServer[WebServer["GraphQLServerPORT"] = 2029] = "GraphQLServerPORT";
13
17
  })(WebServer || (exports.WebServer = WebServer = {}));
14
18
  //# sourceMappingURL=Keys.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Keys.js","sourceRoot":"","sources":["../../../source/config/Keys/Keys.ts"],"names":[],"mappings":";;;AAAA,IAAY,OAGX;AAHD,WAAY,OAAO;IACjB,+BAAoB,CAAA;IACpB,oCAAyB,CAAA;AAC3B,CAAC,EAHW,OAAO,uBAAP,OAAO,QAGlB;AAED,2BAA2B;AAC3B,IAAY,SAEX;AAFD,WAAY,SAAS;IACnB,wDAAiB,CAAA;AACnB,CAAC,EAFW,SAAS,yBAAT,SAAS,QAEpB"}
1
+ {"version":3,"file":"Keys.js","sourceRoot":"","sources":["../../../source/config/Keys/Keys.ts"],"names":[],"mappings":";;;AAAA,IAAY,OAGX;AAHD,WAAY,OAAO;IACjB,+BAAoB,CAAA;IACpB,oCAAyB,CAAA;AAC3B,CAAC,EAHW,OAAO,uBAAP,OAAO,QAGlB;AAED,2BAA2B;AAC3B,IAAY,SAMX;AAND,WAAY,SAAS;IACnB,oEAAuB,CAAA;IACvB,8DAAoB,CAAA;IACpB,8DAAoB,CAAA;IACpB,0EAA0B,CAAA;IAC1B,sEAAwB,CAAA;AAC1B,CAAC,EANW,SAAS,yBAAT,SAAS,QAMpB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "axiodb",
3
- "version": "1.7.5",
3
+ "version": "1.7.9",
4
4
  "description": "A blazing-fast, lightweight, and scalable nodejs package based DBMS for modern applications. Supports schemas, encryption, and advanced query capabilities.",
5
5
  "main": "./lib/config/DB.js",
6
6
  "types": "./lib/config/DB.d.ts",