axiodb 1.4.2 → 1.5.4

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
@@ -1,277 +1,274 @@
1
1
  # AxioDB
2
2
 
3
- AxioDB is a fast, lightweight, and scalable open-source DBMS designed for modern applications. It supports JSON-based data storage, simple APIs, and secure data management, making it ideal for projects requiring efficient and flexible database solutions.
3
+ AxioDB is a fast, lightweight, and scalable open-source DBMS designed for modern applications. It supports `.axiodb` file-based data storage, simple APIs, and secure data management, making it ideal for projects requiring efficient and flexible database solutions.
4
4
 
5
- ## Features
5
+ AxioDB is specifically designed for small to medium-sized websites, blogs, and personal projects. While it provides excellent performance for these use cases, please note that it is currently optimized for smaller data loads rather than massive enterprise-level datasets. We are continuously working to improve performance and scalability in future updates.
6
6
 
7
- - **Custom Schema Support:** Define custom schemas to structure your data for consistency and validation.
8
- - **Chainable Query Methods:** Use familiar methods like `.find()`, `.skip()`, and `.limit()` for powerful query filtering.
9
- - **Node.js Streams for Efficient Read/Write:** Seamlessly handle large datasets with Node.js streams to avoid performance bottlenecks.
10
- - **Custom Data Storage:** Save and retrieve data directly from JSON files without needing a database server.
11
- - **Flexible Indexing:** Implement indexing to speed up query performance.
12
- - **Secure and Reliable:** Includes optional encryption to protect sensitive data stored in your JSON files.
13
- - **Simple Setup and Lightweight:** No additional database setup required; simply install and start using.
7
+ ---
14
8
 
15
- ## Installation
9
+ ## 🚀 Features
16
10
 
17
- To get started with AxioDB, install it via npm:
11
+ - **Schema Support:** Define schemas to structure your data for consistency and validation.
12
+ - **Chainable Query Methods:** Use methods like `.query()`, `.Sort()`, `.Limit()`, and `.Skip()` for powerful query filtering.
13
+ - **Node.js Streams for Efficiency:** Handle large datasets seamlessly with optimized read/write operations.
14
+ - **Encryption Support:** Secure sensitive data with optional encryption for collections.
15
+ - **Aggregation Pipelines:** Perform advanced data operations like `$match`, `$sort`, `$group`, and more.
16
+ - **Simple Setup:** No additional database server required—just install and start using.
18
17
 
19
- ```shell
20
- npm install axiodb@latest --save
21
- ```
18
+ ---
22
19
 
23
- ## Usage
20
+ ## 🔮 Future Plans
24
21
 
25
- ### CommonJS
22
+ We're actively working to enhance AxioDB with several exciting features and improvements:
26
23
 
27
- ```js
28
- const { AxioDB, SchemaTypes } = require("axiodb");
24
+ - **In-Memory Cache Strategy:** Implementing an efficient caching mechanism to significantly speed up query operations.
25
+ - **Performance Optimizations:** Continuous improvements to make data handling faster and more efficient.
26
+ - **Extended Query Capabilities:** Additional operators and more flexible querying options.
27
+ - **Improved Documentation:** More examples, tutorials, and API references.
28
+ - **Better TypeScript Support:** Enhanced type definitions for better developer experience.
29
29
 
30
- // Initialize AxioDB
31
- const db = new AxioDB();
30
+ We invite all developer enthusiasts to contribute to making AxioDB more reliable and powerful. Your insights and contributions can help shape the future of this project!
32
31
 
33
- // Create a new database
34
- db.createDB("myDatabase").then(async (database) => {
35
- // Define a schema
36
- const userSchema = {
37
- name: SchemaTypes.string().required(),
38
- age: SchemaTypes.number().required(),
39
- };
32
+ ---
40
33
 
41
- // Create a new collection with schema
42
- const users = await database.createCollection("users", userSchema);
34
+ ## 📦 Installation
43
35
 
44
- // Insert a document
45
- users.insert({ name: "John Doe", age: 30 }).then((response) => {
46
- console.log("Insert Response:", response);
47
- });
36
+ Install AxioDB via npm:
48
37
 
49
- // Query documents
50
- users
51
- .query({ age: { $gt: 25 } })
52
- .exac()
53
- .then((response) => {
54
- console.log("Query Response:", response);
55
- });
56
- });
38
+ ```bash
39
+ npm install axiodb@latest --save
57
40
  ```
58
41
 
59
- ### ES6
42
+ ---
60
43
 
61
- ```js
62
- import { AxioDB, schemaValidate, SchemaTypes } from "axiodb";
44
+ ## 🛠️ Usage
45
+
46
+ ### CommonJS Example
47
+
48
+ ```javascript
49
+ const { AxioDB, SchemaTypes } = require("axiodb");
63
50
 
64
51
  // Initialize AxioDB
65
52
  const db = new AxioDB();
66
53
 
67
- // Create a new database
68
- db.createDB("myDatabase").then(async (database) => {
54
+ const main = async () => {
55
+ // Create a database
56
+ const database = await db.createDB("myDatabase");
57
+
69
58
  // Define a schema
70
59
  const userSchema = {
71
60
  name: SchemaTypes.string().required(),
72
61
  age: SchemaTypes.number().required(),
73
62
  };
74
63
 
75
- // Create a new collection with schema
64
+ // Create a collection with schema
76
65
  const users = await database.createCollection("users", userSchema);
77
66
 
78
- // Insert a document
79
- users.insert({ name: "John Doe", age: 30 }).then((response) => {
80
- console.log("Insert Response:", response);
81
- });
67
+ // Insert data
68
+ await users.insert({ name: "John Doe", age: 30 });
82
69
 
83
- // Query documents
84
- users
70
+ // Query data
71
+ const result = await users
85
72
  .query({ age: { $gt: 25 } })
86
- .exac()
87
- .then((response) => {
88
- console.log("Query Response:", response);
89
- });
90
- });
73
+ .Limit(10)
74
+ .exec();
75
+ console.log("Query Result:", result);
76
+ };
77
+
78
+ main();
91
79
  ```
92
80
 
93
- ### Additional Features
81
+ ---
82
+
83
+ ## 🌟 Advanced Features
94
84
 
95
- #### Creating Multiple Databases and Collections & Deletations of Database
85
+ ### 1. **Creating Multiple Databases and Collections**
96
86
 
97
- ```js
87
+ ```javascript
98
88
  const { AxioDB, SchemaTypes } = require("axiodb");
99
89
 
100
90
  const db = new AxioDB();
101
91
 
102
- const insertCode = async () => {
92
+ const setup = async () => {
103
93
  const schema = {
104
94
  name: SchemaTypes.string().required().max(15),
105
95
  age: SchemaTypes.number().required().min(18),
106
96
  };
107
97
 
108
98
  const DB1 = await db.createDB("DB1");
109
- const DB2 = await db.createDB("DB2");
110
- const collection = await DB1.createCollection(
99
+ const collection1 = await DB1.createCollection(
111
100
  "collection1",
112
101
  schema,
113
102
  true,
114
- "Ankan",
103
+ "secretKey",
115
104
  );
116
- const collection2 = await DB1.createCollection("collection2", schema, false);
117
105
 
118
106
  // Insert data
119
107
  for (let i = 0; i < 300; i++) {
120
- await collection
121
- .insert({
122
- name: `Ankan${i}`,
123
- age: i + 18,
124
- })
125
- .then((data) => {
126
- console.log(data);
127
- collection
128
- .insert({
129
- name: `Saha${i}`,
130
- age: i + 18,
131
- })
132
- .then(console.log);
133
- });
108
+ await collection1.insert({ name: `User${i}`, age: i + 18 });
134
109
  }
135
110
 
136
111
  // Query data
137
- collection
112
+ const results = await collection1
138
113
  .query({})
139
114
  .Sort({ age: -1 })
140
- .Skip(2)
141
115
  .Limit(10)
142
- .exec()
143
- .then(console.log);
116
+ .exec();
117
+ console.log("Query Results:", results);
144
118
 
145
119
  // Delete collection
146
- DB1.deleteCollection("collection1").then(console.log);
147
-
148
- // Get collection info
149
- DB1.getCollectionInfo().then(console.log);
150
-
151
- // Delete databases
152
- db.deleteDatabase("DB2").then(console.log);
153
- db.deleteDatabase("DB1").then(console.log);
120
+ await DB1.deleteCollection("collection1");
154
121
  };
155
122
 
156
- insertCode();
123
+ setup();
157
124
  ```
158
125
 
159
- ## Encryption
126
+ ---
160
127
 
161
- AxioDB supports optional encryption to protect sensitive data stored in your JSON files. You can enable encryption when creating a collection by passing the `crypto` flag and an encryption key.
128
+ ### 2. **Aggregation Pipelines**
162
129
 
163
- ### Example with Encryption
130
+ Perform advanced operations like filtering, sorting, grouping, and projecting data.
164
131
 
165
- ```js
166
- import { AxioDB, SchemaTypes } from "axiodb";
132
+ ```javascript
133
+ const aggregationResult = await collection1
134
+ .aggregate([
135
+ { $match: { name: { $regex: "User" } } },
136
+ { $project: { name: 1, age: 1 } },
137
+ { $sort: { age: -1 } },
138
+ { $limit: 10 },
139
+ ])
140
+ .exec();
167
141
 
168
- // Initialize AxioDB
169
- const db = new AxioDB();
142
+ console.log("Aggregation Result:", aggregationResult);
143
+ ```
170
144
 
171
- // Create a new database
172
- db.createDB("myDatabase").then(async (database) => {
173
- // Define a schema
174
- const userSchema = {
175
- name: SchemaTypes.string().required(),
176
- age: SchemaTypes.number().required(),
177
- };
145
+ ---
178
146
 
179
- // Create a new collection with schema and encryption
180
- const users = await database.createCollection(
181
- "users",
182
- userSchema,
183
- true,
184
- "mySecretKey",
185
- );
147
+ ### 3. **Encryption**
186
148
 
187
- // Insert a document
188
- users.insert({ name: "John Doe", age: 30 }).then((response) => {
189
- console.log("Insert Response:", response);
190
- });
149
+ Enable encryption for sensitive data by providing a secret key during collection creation.
191
150
 
192
- // Query documents
193
- users
194
- .query({ age: { $gt: 25 } })
195
- .exac()
196
- .then((response) => {
197
- console.log("Query Response:", response);
198
- });
199
- });
151
+ ```javascript
152
+ const encryptedCollection = await DB1.createCollection(
153
+ "secureCollection",
154
+ schema,
155
+ true,
156
+ "mySecretKey",
157
+ );
158
+
159
+ // Insert encrypted data
160
+ await encryptedCollection.insert({ name: "Encrypted User", age: 25 });
161
+
162
+ // Query encrypted data
163
+ const encryptedResult = await encryptedCollection.query({ age: 25 }).exec();
164
+ console.log("Encrypted Query Result:", encryptedResult);
200
165
  ```
201
166
 
202
- ## Motivation
167
+ ---
203
168
 
204
- As a MERN Stack Developer, I encountered several challenges with existing database solutions:
169
+ ### 4. **Update and Delete Operations**
205
170
 
206
- 1. **Complex Setup:** Many databases require complex setup and configuration, which can be time-consuming and error-prone.
207
- 2. **Performance Bottlenecks:** Handling large datasets efficiently was often a challenge, especially with traditional databases.
208
- 3. **Flexibility:** I needed a flexible solution that could easily adapt to different project requirements without extensive modifications.
209
- 4. **Security:** Ensuring data security and encryption was crucial, but existing solutions often lacked easy-to-implement encryption features.
171
+ #### Update Documents
210
172
 
211
- These pain points motivated me to develop AxioDB, a DBMS Npm Package that addresses these issues by providing a simple, efficient, and secure database solution for modern applications.
173
+ ```javascript
174
+ // Update a single document
175
+ await collection1
176
+ .update({ age: 20 })
177
+ .UpdateOne({ name: "Updated User", gender: "Male" });
212
178
 
213
- ## Development Status
179
+ // Update multiple documents
180
+ await collection1
181
+ .update({ name: { $regex: "User" } })
182
+ .UpdateMany({ isActive: true });
183
+ ```
214
184
 
215
- **Note:** This project is currently in development mode and is not stable. Features and APIs may change, and there may be bugs. Use it at your own risk and contribute to its development if possible.
185
+ #### Delete Documents
216
186
 
217
- ## API Reference
187
+ ```javascript
188
+ // Delete a single document
189
+ await collection1.delete({ name: "User1" }).deleteOne();
218
190
 
219
- ### AxioDB
191
+ // Delete multiple documents
192
+ await collection1.delete({ age: { $lt: 25 } }).deleteMany();
193
+ ```
220
194
 
221
- - **createDB(dbName: string): Promise<Database>**
195
+ ---
222
196
 
223
- - Creates a new database with the specified name.
197
+ ## 📖 API Reference
224
198
 
225
- - **deleteDatabase(dbName: string): Promise<SuccessInterface | ErrorInterface>**
226
- - Deletes the specified database.
199
+ ### AxioDB
227
200
 
228
- ### Database
201
+ - **`createDB(dbName: string): Promise<Database>`**
202
+ Creates a new database.
229
203
 
230
- - **createCollection(collectionName: string, schema: object, crypto?: boolean, key?: string): Promise<Collection>**
204
+ - **`deleteDatabase(dbName: string): Promise<SuccessInterface | ErrorInterface>`**
205
+ Deletes a database.
231
206
 
232
- - Creates a new collection with the specified name and schema.
207
+ ### Database
233
208
 
234
- - **deleteCollection(collectionName: string): Promise<SuccessInterface | ErrorInterface>**
209
+ - **`createCollection(name: string, schema: object, crypto?: boolean, key?: string): Promise<Collection>`**
210
+ Creates a collection with an optional schema and encryption.
235
211
 
236
- - Deletes the specified collection from the database.
212
+ - **`deleteCollection(name: string): Promise<SuccessInterface | ErrorInterface>`**
213
+ Deletes a collection.
237
214
 
238
- - **getCollectionInfo(): Promise<SuccessInterface>**
239
- - Retrieves information about all collections in the database.
215
+ - **`getCollectionInfo(): Promise<SuccessInterface>`**
216
+ Retrieves information about all collections.
240
217
 
241
218
  ### Collection
242
219
 
243
- - **insert(data: object): Promise<SuccessInterface | ErrorInterface>**
220
+ - **`insert(data: object): Promise<SuccessInterface | ErrorInterface>`**
221
+ Inserts a document into the collection.
244
222
 
245
- - Inserts a document into the collection.
223
+ - **`query(query: object): Reader`**
224
+ Queries documents in the collection.
246
225
 
247
- - **query(query: object): Reader**
248
- - Queries documents in the collection.
226
+ - **`aggregate(pipeline: object[]): Aggregation`**
227
+ Performs aggregation operations.
249
228
 
250
229
  ### Reader
251
230
 
252
- - **exac(callback?: Function): Promise<SuccessInterface | ErrorInterface>**
231
+ - **`Limit(limit: number): Reader`**
232
+ Sets a limit on the number of documents.
233
+
234
+ - **`Skip(skip: number): Reader`**
235
+ Skips a number of documents.
236
+
237
+ - **`Sort(sort: object): Reader`**
238
+ Sorts the query results.
239
+
240
+ - **`exec(): Promise<SuccessInterface | ErrorInterface>`**
241
+ Executes the query.
242
+
243
+ ---
244
+
245
+ ## 🔒 Security
246
+
247
+ AxioDB prioritizes data security with features like:
248
+
249
+ - Optional encryption for collections.
250
+ - Secure `.axiodb` file-based storage.
253
251
 
254
- - Executes the query and returns the results.
252
+ For vulnerabilities, please refer to the [SECURITY.md](SECURITY.md) file.
255
253
 
256
- - **Limit(limit: number): Reader**
254
+ ---
257
255
 
258
- - Sets a limit on the number of documents to return.
256
+ ## 🤝 Contributing
259
257
 
260
- - **Skip(skip: number): Reader**
258
+ As the sole developer working on this project while maintaining a full-time software engineering career, it can be challenging to dedicate as much time as I'd like to AxioDB's development. If you find this project valuable and believe it solves problems for you, your contributions would be greatly appreciated.
261
259
 
262
- - Sets the number of documents to skip.
260
+ Whether it's code improvements, documentation updates, bug reports, or feature suggestions - every contribution helps make this project better for everyone. Please read the [CONTRIBUTING.md](CONTRIBUTING.md) file for guidelines on how to get started.
263
261
 
264
- - **Sort(sort: object): Reader**
265
- - Sets the sort order for the query.
262
+ Together, we can build something remarkable that serves the needs of the developer community!
266
263
 
267
- ## Contributing
264
+ ---
268
265
 
269
- Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.
266
+ ## 📜 License
270
267
 
271
- ## License
268
+ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
272
269
 
273
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
270
+ ---
274
271
 
275
- ## Acknowledgments
272
+ ## 🙌 Acknowledgments
276
273
 
277
- - Thanks to all contributors and supporters of this project.
274
+ Special thanks to all contributors and supporters of AxioDB. Your feedback and contributions make this project better!
@@ -8,9 +8,10 @@
8
8
  export default class InMemoryCache {
9
9
  private readonly ttl;
10
10
  private cacheObject;
11
+ private tempSearchQuery;
11
12
  /**
12
13
  * Creates a new instance of the cache operation class
13
- * @param TTL - Time to live in seconds for cache entries. Defaults to 60 seconds
14
+ * @param TTL - Time to live in seconds for cache entries. Defaults to 86400 seconds (24 hours)
14
15
  */
15
16
  constructor(TTL?: string | number);
16
17
  /**
@@ -33,4 +34,5 @@ export default class InMemoryCache {
33
34
  * @returns A Promise that resolves to the cached value if found and not expired, null otherwise
34
35
  */
35
36
  getCache(key: string): Promise<any>;
37
+ private autoResetCache;
36
38
  }
@@ -20,9 +20,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
20
20
  class InMemoryCache {
21
21
  /**
22
22
  * Creates a new instance of the cache operation class
23
- * @param TTL - Time to live in seconds for cache entries. Defaults to 60 seconds
23
+ * @param TTL - Time to live in seconds for cache entries. Defaults to 86400 seconds (24 hours)
24
24
  */
25
- constructor(TTL = 60) {
25
+ constructor(TTL = 86400) {
26
+ this.tempSearchQuery = [];
26
27
  this.ttl = typeof TTL === "string" ? parseInt(TTL) : TTL;
27
28
  this.cacheObject = {};
28
29
  }
@@ -43,7 +44,7 @@ class InMemoryCache {
43
44
  return __awaiter(this, void 0, void 0, function* () {
44
45
  this.cacheObject[key] = {
45
46
  value: value,
46
- expiry: Date.now() + this.ttl * 1000,
47
+ expiry: Date.now() + parseInt(String(this.ttl)) * 1000,
47
48
  };
48
49
  });
49
50
  }
@@ -65,6 +66,13 @@ class InMemoryCache {
65
66
  return cacheItem.value;
66
67
  });
67
68
  }
69
+ autoResetCache() {
70
+ return __awaiter(this, void 0, void 0, function* () {
71
+ setInterval(() => {
72
+ this.cacheObject = {};
73
+ }, parseInt(String(this.ttl)));
74
+ });
75
+ }
68
76
  }
69
77
  exports.default = InMemoryCache;
70
78
  //# sourceMappingURL=cache.operation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cache.operation.js","sourceRoot":"","sources":["../../source/Caching/cache.operation.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,uDAAuD;AACvD;;;;;;IAMI;AACJ,MAAqB,aAAa;IAKhC;;;OAGG;IACH,YAAY,MAAuB,EAAE;QACnC,IAAI,CAAC,GAAG,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QACzD,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACxB,CAAC;IAED;;;;;;;;;;;;OAYG;IACU,QAAQ,CAAC,GAAW,EAAE,KAAU;;YAC3C,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG;gBACtB,KAAK,EAAE,KAAK;gBACZ,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,GAAG,IAAI;aACrC,CAAC;QACJ,CAAC;KAAA;IAED;;;;OAIG;IACU,QAAQ,CAAC,GAAW;;YAC/B,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;YACxC,IAAI,CAAC,SAAS,EAAE,CAAC;gBACf,OAAO,IAAI,CAAC;YACd,CAAC;YACD,IAAI,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;gBAClC,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;gBAC7B,OAAO,IAAI,CAAC;YACd,CAAC;YACD,OAAO,SAAS,CAAC,KAAK,CAAC;QACzB,CAAC;KAAA;CACF;AAlDD,gCAkDC"}
1
+ {"version":3,"file":"cache.operation.js","sourceRoot":"","sources":["../../source/Caching/cache.operation.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,uDAAuD;AACvD;;;;;;IAMI;AACJ,MAAqB,aAAa;IAKhC;;;OAGG;IACH,YAAY,MAAuB,KAAK;QALhC,oBAAe,GAAU,EAAE,CAAC;QAMlC,IAAI,CAAC,GAAG,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QACzD,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACxB,CAAC;IAED;;;;;;;;;;;;OAYG;IACU,QAAQ,CAAC,GAAW,EAAE,KAAU;;YAC3C,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG;gBACtB,KAAK,EAAE,KAAK;gBACZ,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI;aACvD,CAAC;QACJ,CAAC;KAAA;IAED;;;;OAIG;IACU,QAAQ,CAAC,GAAW;;YAC/B,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;YACxC,IAAI,CAAC,SAAS,EAAE,CAAC;gBACf,OAAO,IAAI,CAAC;YACd,CAAC;YACD,IAAI,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;gBAClC,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;gBAC7B,OAAO,IAAI,CAAC;YACd,CAAC;YACD,OAAO,SAAS,CAAC,KAAK,CAAC;QACzB,CAAC;KAAA;IAEa,cAAc;;YAC1B,WAAW,CACT,GAAG,EAAE;gBACH,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;YACxB,CAAC,EACD,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAC3B,CAAC;QACJ,CAAC;KAAA;CACF;AA3DD,gCA2DC"}
@@ -0,0 +1,57 @@
1
+ import { ErrorInterface, SuccessInterface } from "../../config/Interfaces/Helper/response.helper.interface";
2
+ /**
3
+ * Class that performs aggregation operations on data.
4
+ *
5
+ * This class allows for MongoDB-like aggregation pipeline operations on collection data.
6
+ * It supports various stages including $match, $group, $sort, $project, $limit, $skip,
7
+ * $unwind, and $addFields.
8
+ *
9
+ * The class can handle both encrypted and non-encrypted data collections.
10
+ */
11
+ export default class Aggregation {
12
+ private AllData;
13
+ private readonly Pipeline;
14
+ private path;
15
+ private readonly collectionName;
16
+ private readonly ResponseHelper;
17
+ private isEncrypted;
18
+ private encryptionKey?;
19
+ private cryptoInstance?;
20
+ private readonly Converter;
21
+ constructor(collectionName: string, path: string, Pipeline: object[] | any, isEncrypted?: boolean, encryptionKey?: string);
22
+ /**
23
+ * Executes the aggregation pipeline on the data.
24
+ *
25
+ * This method processes the aggregation pipeline stages in sequence:
26
+ * - $match: Filters documents based on specified conditions
27
+ * - $group: Groups documents by specified fields and applies aggregation operations
28
+ * - $sort: Sorts documents based on specified fields and order
29
+ * - $project: Reshapes documents by including specified fields
30
+ * - $limit: Limits the number of documents in the result
31
+ * - $skip: Skips a specified number of documents
32
+ * - $unwind: Deconstructs an array field from input documents
33
+ * - $addFields: Adds new fields to documents
34
+ *
35
+ * The method first validates if the pipeline is an array, loads all buffer data,
36
+ * and then processes each stage of the pipeline sequentially.
37
+ *
38
+ * @throws {Error} If the pipeline is not an array
39
+ * @returns {Array<any>} The result of the aggregation pipeline
40
+ */
41
+ exec(): Promise<SuccessInterface | ErrorInterface>;
42
+ /**
43
+ * Loads all buffer raw data from the specified directory.
44
+ *
45
+ * This method performs the following steps:
46
+ * 1. Checks if the directory is locked.
47
+ * 2. If the directory is not locked, it lists all files in the directory.
48
+ * 3. Reads each file and decrypts the data if encryption is enabled.
49
+ * 4. Stores the decrypted data in the `AllData` array.
50
+ * 5. If the directory is locked, it unlocks the directory, reads the files, and then locks the directory again.
51
+ *
52
+ * @returns {Promise<SuccessInterface | ErrorInterface>} A promise that resolves to a success or error response.
53
+ *
54
+ * @throws {Error} Throws an error if any operation fails.
55
+ */
56
+ private LoadAllBufferRawData;
57
+ }
@@ -0,0 +1,305 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const response_helper_1 = __importDefault(require("../../Helper/response.helper"));
16
+ const Crypto_helper_1 = require("../../Helper/Crypto.helper");
17
+ const FolderManager_1 = __importDefault(require("../../Storage/FolderManager"));
18
+ const FileManager_1 = __importDefault(require("../../Storage/FileManager"));
19
+ const Converter_helper_1 = __importDefault(require("../../Helper/Converter.helper"));
20
+ const outers_1 = require("outers");
21
+ /**
22
+ * Class that performs aggregation operations on data.
23
+ *
24
+ * This class allows for MongoDB-like aggregation pipeline operations on collection data.
25
+ * It supports various stages including $match, $group, $sort, $project, $limit, $skip,
26
+ * $unwind, and $addFields.
27
+ *
28
+ * The class can handle both encrypted and non-encrypted data collections.
29
+ */
30
+ class Aggregation {
31
+ constructor(collectionName, path, Pipeline, isEncrypted = false, encryptionKey) {
32
+ // property to store the data
33
+ this.AllData = [];
34
+ this.collectionName = collectionName;
35
+ this.path = path;
36
+ this.isEncrypted = isEncrypted;
37
+ this.encryptionKey = encryptionKey;
38
+ this.AllData = [];
39
+ this.Pipeline = Pipeline;
40
+ this.ResponseHelper = new response_helper_1.default();
41
+ this.Converter = new Converter_helper_1.default();
42
+ this.cryptoInstance = new Crypto_helper_1.CryptoHelper(this.encryptionKey);
43
+ }
44
+ /**
45
+ * Executes the aggregation pipeline on the data.
46
+ *
47
+ * This method processes the aggregation pipeline stages in sequence:
48
+ * - $match: Filters documents based on specified conditions
49
+ * - $group: Groups documents by specified fields and applies aggregation operations
50
+ * - $sort: Sorts documents based on specified fields and order
51
+ * - $project: Reshapes documents by including specified fields
52
+ * - $limit: Limits the number of documents in the result
53
+ * - $skip: Skips a specified number of documents
54
+ * - $unwind: Deconstructs an array field from input documents
55
+ * - $addFields: Adds new fields to documents
56
+ *
57
+ * The method first validates if the pipeline is an array, loads all buffer data,
58
+ * and then processes each stage of the pipeline sequentially.
59
+ *
60
+ * @throws {Error} If the pipeline is not an array
61
+ * @returns {Array<any>} The result of the aggregation pipeline
62
+ */
63
+ exec() {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ if (!Array.isArray(this.Pipeline)) {
66
+ throw new Error("Pipeline must be an array of aggregation stages.");
67
+ }
68
+ // Load all buffer raw data from the specified directory
69
+ yield this.LoadAllBufferRawData().then((response) => {
70
+ if ("data" in response) {
71
+ outers_1.Console.green("Data Loaded Successfully for Aggregation");
72
+ }
73
+ });
74
+ let result = [...this.AllData];
75
+ for (const stage of this.Pipeline) {
76
+ if (stage.$match) {
77
+ result = result.filter((item) => {
78
+ return Object.entries(stage.$match).every(([key, value]) => {
79
+ var _a;
80
+ const itemValue = (_a = item[key]) !== null && _a !== void 0 ? _a : ""; // Ensure item[key] exists
81
+ if (typeof value === "string" ||
82
+ typeof value === "number" ||
83
+ typeof value === "boolean") {
84
+ return itemValue === value;
85
+ }
86
+ if (typeof value === "object" && value !== null) {
87
+ if (value instanceof RegExp) {
88
+ return value.test(itemValue);
89
+ }
90
+ if ("$regex" in value) {
91
+ const regexPattern = value.$regex;
92
+ const regexOptions = "$options" in value ? value.$options : "";
93
+ try {
94
+ const regex = new RegExp(String(regexPattern), regexOptions);
95
+ return regex.test(itemValue);
96
+ }
97
+ catch (error) {
98
+ outers_1.Console.red(`Invalid regex: ${regexPattern} with options: ${regexOptions}`, error);
99
+ return false;
100
+ }
101
+ }
102
+ }
103
+ return false;
104
+ });
105
+ });
106
+ }
107
+ if (stage.$group) {
108
+ const groupedData = {};
109
+ for (const item of result) {
110
+ let groupKey;
111
+ if (typeof stage.$group._id === "string") {
112
+ groupKey = stage.$group._id.startsWith("$")
113
+ ? item[stage.$group._id.substring(1)]
114
+ : stage.$group._id;
115
+ }
116
+ else if (typeof stage.$group._id === "object") {
117
+ groupKey = JSON.stringify(Object.entries(stage.$group._id).reduce((acc, [k, v]) => {
118
+ const fieldPath = v.replace("$", "");
119
+ acc[k] = item[fieldPath];
120
+ return acc;
121
+ }, {}));
122
+ }
123
+ else {
124
+ groupKey = "null";
125
+ }
126
+ if (!groupedData[groupKey]) {
127
+ groupedData[groupKey] = { _id: groupKey };
128
+ }
129
+ for (const [key, operation] of Object.entries(stage.$group)) {
130
+ if (key === "_id")
131
+ continue;
132
+ if (operation.$avg) {
133
+ const field = operation.$avg.replace("$", "");
134
+ groupedData[groupKey][key] = groupedData[groupKey][key] || {
135
+ sum: 0,
136
+ count: 0,
137
+ };
138
+ groupedData[groupKey][key].sum += item[field];
139
+ groupedData[groupKey][key].count += 1;
140
+ }
141
+ if (operation.$sum) {
142
+ const field = operation.$sum.replace("$", "");
143
+ groupedData[groupKey][key] =
144
+ (groupedData[groupKey][key] || 0) + item[field];
145
+ }
146
+ }
147
+ }
148
+ result = Object.values(groupedData).map((group) => {
149
+ for (const key in group) {
150
+ if (group[key] && group[key].sum !== undefined) {
151
+ group[key] = group[key].sum / group[key].count;
152
+ }
153
+ }
154
+ return group;
155
+ });
156
+ }
157
+ if (stage.$sort) {
158
+ const [[key, order]] = Object.entries(stage.$sort);
159
+ const numOrder = Number(order);
160
+ result.sort((a, b) => {
161
+ if (a[key] < b[key])
162
+ return -numOrder;
163
+ if (a[key] > b[key])
164
+ return numOrder;
165
+ return 0;
166
+ });
167
+ }
168
+ if (stage.$project) {
169
+ result = result.map((item) => {
170
+ const projected = {};
171
+ for (const key in stage.$project) {
172
+ if (stage.$project[key] === 1) {
173
+ projected[key] = item[key];
174
+ }
175
+ }
176
+ return projected;
177
+ });
178
+ }
179
+ if (stage.$limit) {
180
+ result = result.slice(0, stage.$limit);
181
+ }
182
+ if (stage.$skip) {
183
+ result = result.slice(stage.$skip);
184
+ }
185
+ if (stage.$unwind) {
186
+ const field = stage.$unwind.replace("$", "");
187
+ result = result.flatMap((item) => {
188
+ return Array.isArray(item[field])
189
+ ? item[field].map((value) => (Object.assign(Object.assign({}, item), { [field]: value })))
190
+ : [item];
191
+ });
192
+ }
193
+ if (stage.$addFields) {
194
+ result = result.map((item) => (Object.assign(Object.assign({}, item), stage.$addFields)));
195
+ }
196
+ }
197
+ return this.ResponseHelper.Success(result);
198
+ });
199
+ }
200
+ /**
201
+ * Loads all buffer raw data from the specified directory.
202
+ *
203
+ * This method performs the following steps:
204
+ * 1. Checks if the directory is locked.
205
+ * 2. If the directory is not locked, it lists all files in the directory.
206
+ * 3. Reads each file and decrypts the data if encryption is enabled.
207
+ * 4. Stores the decrypted data in the `AllData` array.
208
+ * 5. If the directory is locked, it unlocks the directory, reads the files, and then locks the directory again.
209
+ *
210
+ * @returns {Promise<SuccessInterface | ErrorInterface>} A promise that resolves to a success or error response.
211
+ *
212
+ * @throws {Error} Throws an error if any operation fails.
213
+ */
214
+ LoadAllBufferRawData() {
215
+ return __awaiter(this, void 0, void 0, function* () {
216
+ try {
217
+ // Check if Directory Locked or not
218
+ const isLocked = yield new FolderManager_1.default().IsDirectoryLocked(this.path);
219
+ if ("data" in isLocked) {
220
+ // If Directory is not locked
221
+ if (isLocked.data === false) {
222
+ // Read List the data from the file
223
+ const ReadResponse = yield new FolderManager_1.default().ListDirectory(this.path);
224
+ if ("data" in ReadResponse) {
225
+ // Store all files in DataFilesList
226
+ const DataFilesList = ReadResponse.data;
227
+ // Read all files from the directory
228
+ for (let i = 0; i < DataFilesList.length; i++) {
229
+ const ReadFileResponse = yield new FileManager_1.default().ReadFile(`${this.path}/${DataFilesList[i]}`);
230
+ // Check if the file is read successfully or not
231
+ if ("data" in ReadFileResponse) {
232
+ if (this.isEncrypted === true && this.cryptoInstance) {
233
+ // Decrypt the data if crypto is enabled
234
+ const ContentResponse = yield this.cryptoInstance.decrypt(this.Converter.ToObject(ReadFileResponse.data));
235
+ // Store all Decrypted Data in AllData
236
+ this.AllData.push(this.Converter.ToObject(ContentResponse));
237
+ }
238
+ else {
239
+ this.AllData.push(this.Converter.ToObject(ReadFileResponse.data));
240
+ }
241
+ }
242
+ else {
243
+ return this.ResponseHelper.Error(`Failed to read file: ${DataFilesList[i]}`);
244
+ }
245
+ }
246
+ return this.ResponseHelper.Success(this.AllData);
247
+ }
248
+ return this.ResponseHelper.Error("Failed to read directory");
249
+ }
250
+ else {
251
+ // if Directory is locked then unlock it
252
+ const unlockResponse = yield new FolderManager_1.default().UnlockDirectory(this.path);
253
+ if ("data" in unlockResponse) {
254
+ // Read List the data from the file
255
+ const ReadResponse = yield new FolderManager_1.default().ListDirectory(this.path);
256
+ if ("data" in ReadResponse) {
257
+ // Store all files in DataFilesList
258
+ const DataFilesList = ReadResponse.data;
259
+ // Read all files from the directory
260
+ for (let i = 0; i < DataFilesList.length; i++) {
261
+ const ReadFileResponse = yield new FileManager_1.default().ReadFile(`${this.path}/${DataFilesList[i]}`);
262
+ // Check if the file is read successfully or not
263
+ if ("data" in ReadFileResponse) {
264
+ if (this.isEncrypted === true && this.cryptoInstance) {
265
+ // Decrypt the data if crypto is enabled
266
+ const ContaentResponse = yield this.cryptoInstance.decrypt(this.Converter.ToObject(ReadFileResponse.data));
267
+ // Store all Decrypted Data in AllData
268
+ this.AllData.push(this.Converter.ToObject(ContaentResponse));
269
+ }
270
+ else {
271
+ this.AllData.push(this.Converter.ToObject(ReadFileResponse.data));
272
+ }
273
+ }
274
+ else {
275
+ return this.ResponseHelper.Error(`Failed to read file: ${DataFilesList[i]}`);
276
+ }
277
+ }
278
+ // Lock the directory after reading all files
279
+ const lockResponse = yield new FolderManager_1.default().LockDirectory(this.path);
280
+ if ("data" in lockResponse) {
281
+ return this.ResponseHelper.Success(this.AllData);
282
+ }
283
+ else {
284
+ return this.ResponseHelper.Error(`Failed to lock directory: ${this.path}`);
285
+ }
286
+ }
287
+ return this.ResponseHelper.Error(`Failed to read directory: ${this.path}`);
288
+ }
289
+ else {
290
+ return this.ResponseHelper.Error(`Failed to unlock directory: ${this.path}`);
291
+ }
292
+ }
293
+ }
294
+ else {
295
+ return this.ResponseHelper.Error(isLocked);
296
+ }
297
+ }
298
+ catch (error) {
299
+ return this.ResponseHelper.Error(error);
300
+ }
301
+ });
302
+ }
303
+ }
304
+ exports.default = Aggregation;
305
+ //# sourceMappingURL=Aggregation.Operation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Aggregation.Operation.js","sourceRoot":"","sources":["../../../source/Operation/Aggregation/Aggregation.Operation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,mFAA0D;AAC1D,8DAA0D;AAK1D,gFAAwD;AACxD,4EAAoD;AACpD,qFAAsD;AACtD,mCAAiC;AAejC;;;;;;;;GAQG;AACH,MAAqB,WAAW;IAY9B,YACE,cAAsB,EACtB,IAAY,EACZ,QAAwB,EACxB,cAAuB,KAAK,EAC5B,aAAsB;QAhBxB,6BAA6B;QACrB,YAAO,GAAU,EAAE,CAAC;QAiB1B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,cAAc,GAAG,IAAI,yBAAc,EAAE,CAAC;QAC3C,IAAI,CAAC,SAAS,GAAG,IAAI,0BAAS,EAAE,CAAC;QACjC,IAAI,CAAC,cAAc,GAAG,IAAI,4BAAY,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC7D,C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CACnD,CAAC;qCAAM,CAAC;oCACN,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAC9B,6BAA6B,IAAI,CAAC,IAAI,EAAE,CACzC,CAAC;gCACJ,CAAC;4BACH,CAAC;4BACD,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAC9B,6BAA6B,IAAI,CAAC,IAAI,EAAE,CACzC,CAAC;wBACJ,CAAC;6BAAM,CAAC;4BACN,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAC9B,+BAA+B,IAAI,CAAC,IAAI,EAAE,CAC3C,CAAC;wBACJ,CAAC;oBACH,CAAC;gBACH,CAAC;qBAAM,CAAC;oBACN,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;gBAC7C,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAC1C,CAAC;QACH,CAAC;KAAA;CACF;AAxUD,8BAwUC"}
@@ -1,8 +1,9 @@
1
1
  import { ErrorInterface, SuccessInterface } from "../../config/Interfaces/Helper/response.helper.interface";
2
2
  import Reader from "../CRUD Operation/Reader.operation";
3
3
  import DeleteOperation from "../CRUD Operation/Delete.operation";
4
- import { CryptoHelper } from "../../Helper/Crypto.helper";
5
4
  import UpdateOperation from "../CRUD Operation/Update.operation";
5
+ import Aggregation from "../Aggregation/Aggregation.Operation";
6
+ import { CryptoHelper } from "../../Helper/Crypto.helper";
6
7
  /**
7
8
  * Represents a collection inside a database.
8
9
  */
@@ -29,6 +30,18 @@ export default class Collection {
29
30
  * @returns {Reader} - An instance of the Reader class.
30
31
  */
31
32
  query(query: object | any): Reader;
33
+ /**
34
+ * Initiates an aggregation operation on the collection with the provided pipeline steps.
35
+ * @param {object[]} PipelineQuerySteps - The pipeline steps to be executed.
36
+ * @returns {Aggregation} - An instance of the Aggregation class.
37
+ * @throws {Error} Throws an error if the pipeline steps are empty.
38
+ * @example
39
+ * ```typescript
40
+ * // Aggregate the collection to get the total count of documents
41
+ * collection.aggregate([{$match: {}}, ${group: {_id: null, count: {$sum: 1}}}]).exec();
42
+ * ```
43
+ */
44
+ aggregate(PipelineQuerySteps: object[]): Aggregation;
32
45
  /**
33
46
  * Initiates a delete operation on the collection with the provided query.
34
47
  *
@@ -16,13 +16,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
16
16
  const Create_operation_1 = __importDefault(require("../CRUD Operation/Create.operation"));
17
17
  const Reader_operation_1 = __importDefault(require("../CRUD Operation/Reader.operation"));
18
18
  const Delete_operation_1 = __importDefault(require("../CRUD Operation/Delete.operation"));
19
+ const Update_operation_1 = __importDefault(require("../CRUD Operation/Update.operation"));
20
+ const Aggregation_Operation_1 = __importDefault(require("../Aggregation/Aggregation.Operation"));
19
21
  const outers_1 = require("outers");
20
22
  // Validator
21
23
  const validator_models_1 = __importDefault(require("../../Models/validator.models"));
22
24
  // Converter
23
25
  const Converter_helper_1 = __importDefault(require("../../Helper/Converter.helper"));
24
26
  const DataTypes_models_1 = require("../../Models/DataTypes.models");
25
- const Update_operation_1 = __importDefault(require("../CRUD Operation/Update.operation"));
26
27
  /**
27
28
  * Represents a collection inside a database.
28
29
  */
@@ -84,6 +85,24 @@ class Collection {
84
85
  // Read the data
85
86
  return new Reader_operation_1.default(this.name, this.path, query, this.isEncrypted, this.encryptionKey);
86
87
  }
88
+ /**
89
+ * Initiates an aggregation operation on the collection with the provided pipeline steps.
90
+ * @param {object[]} PipelineQuerySteps - The pipeline steps to be executed.
91
+ * @returns {Aggregation} - An instance of the Aggregation class.
92
+ * @throws {Error} Throws an error if the pipeline steps are empty.
93
+ * @example
94
+ * ```typescript
95
+ * // Aggregate the collection to get the total count of documents
96
+ * collection.aggregate([{$match: {}}, ${group: {_id: null, count: {$sum: 1}}}]).exec();
97
+ * ```
98
+ */
99
+ aggregate(PipelineQuerySteps) {
100
+ // Check if Pipeline Steps is valid Array of Object
101
+ if (!PipelineQuerySteps) {
102
+ throw new Error("Please provide valid Pipeline Steps");
103
+ }
104
+ return new Aggregation_Operation_1.default(this.name, this.path, PipelineQuerySteps, this.isEncrypted, this.encryptionKey);
105
+ }
87
106
  /**
88
107
  * Initiates a delete operation on the collection with the provided query.
89
108
  *
@@ -1 +1 @@
1
- {"version":3,"file":"collection.operation.js","sourceRoot":"","sources":["../../../source/Operation/Collection/collection.operation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAKA,aAAa;AACb,0FAA2D;AAC3D,0FAAwD;AACxD,0FAAiE;AAEjE,mCAAiC;AACjC,YAAY;AACZ,qFAA4D;AAG5D,YAAY;AACZ,qFAAsD;AACtD,oEAA4D;AAC5D,0FAAiE;AAEjE;;GAEG;AACH,MAAqB,UAAU;IAW7B,YACE,IAAY,EACZ,IAAY,EACZ,KAAmB,EACnB,WAAW,GAAG,KAAK,EACnB,cAA6B,EAC7B,aAAsB;QAEtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,SAAS,GAAG,IAAI,0BAAS,EAAE,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAC1C,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,iCAAiC;QACjC,IAAI,CAAC,SAAS,GAAG,IAAI,0BAAS,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC;IAED;;;;OAIG;IACU,MAAM,CACjB,IAAkB;;YAElB,gCAAgC;YAChC,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;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AED;;;;;;;;;;;;OAYG;IACI,MAAM,CAAC,KAAmB;QAC/B,sCAAsC;QACtC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAC3C,CAAC;QACD,kBAAkB;QAClB,OAAO,IAAI,0BAAe,CACxB,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,IAAI,EACT,KAAK,EACL,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,aAAa,CACnB,CAAC;IACJ,CAAC;IAEM,MAAM,CAAC,KAAmB;QAC/B,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAC3C,CAAC;QACD,OAAO,IAAI,0BAAe,CACxB,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,IAAI,EACT,KAAK,EACL,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,aAAa,CACnB,CAAC;IACJ,CAAC;CACF;AApID,6BAoIC"}
1
+ {"version":3,"file":"collection.operation.js","sourceRoot":"","sources":["../../../source/Operation/Collection/collection.operation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAKA,aAAa;AACb,0FAA2D;AAC3D,0FAAwD;AACxD,0FAAiE;AACjE,0FAAiE;AACjE,iGAA+D;AAE/D,mCAAiC;AACjC,YAAY;AACZ,qFAA4D;AAG5D,YAAY;AACZ,qFAAsD;AACtD,oEAA4D;AAE5D;;GAEG;AACH,MAAqB,UAAU;IAW7B,YACE,IAAY,EACZ,IAAY,EACZ,KAAmB,EACnB,WAAW,GAAG,KAAK,EACnB,cAA6B,EAC7B,aAAsB;QAEtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC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C,CAAC;QACD,OAAO,IAAI,0BAAe,CACxB,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,IAAI,EACT,KAAK,EACL,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,aAAa,CACnB,CAAC;IACJ,CAAC;CACF;AA7JD,6BA6JC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "axiodb",
3
- "version": "1.4.2",
3
+ "version": "1.5.4",
4
4
  "description": "A fast, lightweight, and scalable open-source DBMS for modern apps. Supports JSON-based data storage, simple APIs, and secure data management. Ideal for projects needing efficient and flexible database solutions.",
5
5
  "main": "./lib/config/DB.js",
6
6
  "types": "./lib/config/DB.d.ts",