axiodb 1.2.9 → 1.2.10
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 +195 -17
- package/lib/Operation/CRUD Operation/Reader.operation.d.ts +43 -0
- package/lib/Operation/CRUD Operation/Reader.operation.js +119 -0
- package/lib/Operation/CRUD Operation/Reader.operation.js.map +1 -0
- package/lib/Operation/Collection/collection.operation.d.ts +7 -0
- package/lib/Operation/Collection/collection.operation.js +14 -0
- package/lib/Operation/Collection/collection.operation.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,29 +1,207 @@
|
|
|
1
1
|
# AxioDB
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
AxioDB is a JSON-based database management system built using Node.js streams, designed to offer an all-in-one solution for data management. It provides a flexible and efficient way to handle data storage, retrieval, and manipulation without the need for a traditional database setup.
|
|
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.
|
|
6
4
|
|
|
7
5
|
## Features
|
|
8
6
|
|
|
9
|
-
- **Custom
|
|
10
|
-
- **
|
|
11
|
-
- **
|
|
12
|
-
- **
|
|
13
|
-
- **
|
|
14
|
-
- **
|
|
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.
|
|
15
14
|
|
|
16
|
-
##
|
|
15
|
+
## Installation
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
To get started with AxioDB, install it via npm:
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
```shell
|
|
20
|
+
npm install axiodb@latest --save
|
|
21
|
+
```
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
## Usage
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
### CommonJS
|
|
26
26
|
|
|
27
|
-
```
|
|
28
|
-
|
|
27
|
+
```js
|
|
28
|
+
const { AxioDB, schemaValidate, SchemaTypes } = require("axiodb");
|
|
29
|
+
|
|
30
|
+
// Initialize AxioDB
|
|
31
|
+
const db = new AxioDB();
|
|
32
|
+
|
|
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
|
+
};
|
|
40
|
+
|
|
41
|
+
// Create a new collection with schema
|
|
42
|
+
const users = await database.createCollection("users", userSchema);
|
|
43
|
+
|
|
44
|
+
// Insert a document
|
|
45
|
+
users.insert({ name: "John Doe", age: 30 }).then((response) => {
|
|
46
|
+
console.log("Insert Response:", response);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Query documents
|
|
50
|
+
users
|
|
51
|
+
.query({ age: { $gt: 25 } })
|
|
52
|
+
.exac()
|
|
53
|
+
.then((response) => {
|
|
54
|
+
console.log("Query Response:", response);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### ES6
|
|
60
|
+
|
|
61
|
+
```js
|
|
62
|
+
import { AxioDB, schemaValidate, SchemaTypes } from "axiodb";
|
|
63
|
+
|
|
64
|
+
// Initialize AxioDB
|
|
65
|
+
const db = new AxioDB();
|
|
66
|
+
|
|
67
|
+
// Create a new database
|
|
68
|
+
db.createDB("myDatabase").then(async (database) => {
|
|
69
|
+
// Define a schema
|
|
70
|
+
const userSchema = {
|
|
71
|
+
name: SchemaTypes.string().required(),
|
|
72
|
+
age: SchemaTypes.number().required(),
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// Create a new collection with schema
|
|
76
|
+
const users = await database.createCollection("users", userSchema);
|
|
77
|
+
|
|
78
|
+
// Insert a document
|
|
79
|
+
users.insert({ name: "John Doe", age: 30 }).then((response) => {
|
|
80
|
+
console.log("Insert Response:", response);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// Query documents
|
|
84
|
+
users
|
|
85
|
+
.query({ age: { $gt: 25 } })
|
|
86
|
+
.exac()
|
|
87
|
+
.then((response) => {
|
|
88
|
+
console.log("Query Response:", response);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
29
91
|
```
|
|
92
|
+
|
|
93
|
+
## Encryption
|
|
94
|
+
|
|
95
|
+
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.
|
|
96
|
+
|
|
97
|
+
### Example with Encryption
|
|
98
|
+
|
|
99
|
+
```js
|
|
100
|
+
import { AxioDB, schemaValidate, SchemaTypes } from "axiodb";
|
|
101
|
+
|
|
102
|
+
// Initialize AxioDB
|
|
103
|
+
const db = new AxioDB();
|
|
104
|
+
|
|
105
|
+
// Create a new database
|
|
106
|
+
db.createDB("myDatabase").then(async (database) => {
|
|
107
|
+
// Define a schema
|
|
108
|
+
const userSchema = {
|
|
109
|
+
name: SchemaTypes.string().required(),
|
|
110
|
+
age: SchemaTypes.number().required(),
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// Create a new collection with schema and encryption
|
|
114
|
+
const users = await database.createCollection(
|
|
115
|
+
"users",
|
|
116
|
+
userSchema,
|
|
117
|
+
true,
|
|
118
|
+
"mySecretKey",
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
// Insert a document
|
|
122
|
+
users.insert({ name: "John Doe", age: 30 }).then((response) => {
|
|
123
|
+
console.log("Insert Response:", response);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// Query documents
|
|
127
|
+
users
|
|
128
|
+
.query({ age: { $gt: 25 } })
|
|
129
|
+
.exac()
|
|
130
|
+
.then((response) => {
|
|
131
|
+
console.log("Query Response:", response);
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Motivation
|
|
137
|
+
|
|
138
|
+
As a MERN Stack Developer, I encountered several challenges with existing database solutions:
|
|
139
|
+
|
|
140
|
+
1. **Complex Setup:** Many databases require complex setup and configuration, which can be time-consuming and error-prone.
|
|
141
|
+
2. **Performance Bottlenecks:** Handling large datasets efficiently was often a challenge, especially with traditional databases.
|
|
142
|
+
3. **Flexibility:** I needed a flexible solution that could easily adapt to different project requirements without extensive modifications.
|
|
143
|
+
4. **Security:** Ensuring data security and encryption was crucial, but existing solutions often lacked easy-to-implement encryption features.
|
|
144
|
+
|
|
145
|
+
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.
|
|
146
|
+
|
|
147
|
+
## Development Status
|
|
148
|
+
|
|
149
|
+
**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.
|
|
150
|
+
|
|
151
|
+
## API Reference
|
|
152
|
+
|
|
153
|
+
### AxioDB
|
|
154
|
+
|
|
155
|
+
- **createDB(dbName: string): Promise<Database>**
|
|
156
|
+
- Creates a new database with the specified name.
|
|
157
|
+
|
|
158
|
+
### Database
|
|
159
|
+
|
|
160
|
+
- **createCollection(collectionName: string, schema: object, crypto?: boolean, key?: string): Promise<Collection>**
|
|
161
|
+
|
|
162
|
+
- Creates a new collection with the specified name and schema.
|
|
163
|
+
|
|
164
|
+
- **deleteCollection(collectionName: string): Promise<SuccessInterface | ErrorInterface>**
|
|
165
|
+
|
|
166
|
+
- Deletes the specified collection from the database.
|
|
167
|
+
|
|
168
|
+
- **getCollectionInfo(): Promise<SuccessInterface>**
|
|
169
|
+
- Retrieves information about all collections in the database.
|
|
170
|
+
|
|
171
|
+
### Collection
|
|
172
|
+
|
|
173
|
+
- **insert(data: object): Promise<SuccessInterface | ErrorInterface>**
|
|
174
|
+
|
|
175
|
+
- Inserts a document into the collection.
|
|
176
|
+
|
|
177
|
+
- **query(query: object): Reader**
|
|
178
|
+
- Queries documents in the collection.
|
|
179
|
+
|
|
180
|
+
### Reader
|
|
181
|
+
|
|
182
|
+
- **exac(callback?: Function): Promise<SuccessInterface | ErrorInterface>**
|
|
183
|
+
|
|
184
|
+
- Executes the query and returns the results.
|
|
185
|
+
|
|
186
|
+
- **Limit(limit: number): Reader**
|
|
187
|
+
|
|
188
|
+
- Sets a limit on the number of documents to return.
|
|
189
|
+
|
|
190
|
+
- **Skip(skip: number): Reader**
|
|
191
|
+
|
|
192
|
+
- Sets the number of documents to skip.
|
|
193
|
+
|
|
194
|
+
- **Sort(sort: object): Reader**
|
|
195
|
+
- Sets the sort order for the query.
|
|
196
|
+
|
|
197
|
+
## Contributing
|
|
198
|
+
|
|
199
|
+
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.
|
|
200
|
+
|
|
201
|
+
## License
|
|
202
|
+
|
|
203
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
204
|
+
|
|
205
|
+
## Acknowledgments
|
|
206
|
+
|
|
207
|
+
- Thanks to all contributors and supporters of this project.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ErrorInterface, SuccessInterface } from "../../config/Interfaces/Helper/response.helper.interface";
|
|
2
|
+
/**
|
|
3
|
+
* Class representing a read operation.
|
|
4
|
+
*/
|
|
5
|
+
export default class Reader {
|
|
6
|
+
private readonly collectionName;
|
|
7
|
+
private readonly path;
|
|
8
|
+
private readonly Converter;
|
|
9
|
+
private readonly baseQuery;
|
|
10
|
+
private limit;
|
|
11
|
+
private skip;
|
|
12
|
+
private sort;
|
|
13
|
+
private isEncrypted;
|
|
14
|
+
/**
|
|
15
|
+
* Creates an instance of Read.
|
|
16
|
+
* @param {string} collectionName - The name of the collection.
|
|
17
|
+
* @param {string | any} path - The data to be read.
|
|
18
|
+
*/
|
|
19
|
+
constructor(collectionName: string, path: string | any, baseQuery: object | any, isEncrypted?: boolean);
|
|
20
|
+
/**
|
|
21
|
+
* Reads the data from a file.
|
|
22
|
+
* @returns {Promise<any>} A promise that resolves with the response of the read operation.
|
|
23
|
+
*/
|
|
24
|
+
exac(callback?: typeof Function): Promise<SuccessInterface | ErrorInterface>;
|
|
25
|
+
/**
|
|
26
|
+
* set limit to the query
|
|
27
|
+
* @param {number} limit - The limit to be set.
|
|
28
|
+
* @returns {Reader} - An instance of the Reader class.
|
|
29
|
+
*/
|
|
30
|
+
Limit(limit: number): Reader;
|
|
31
|
+
/**
|
|
32
|
+
* to be skipped to the query
|
|
33
|
+
* @param {number} skip - The skip to be set.
|
|
34
|
+
* @returns {Reader} - An instance of the Reader class.
|
|
35
|
+
*/
|
|
36
|
+
Skip(skip: number): Reader;
|
|
37
|
+
/**
|
|
38
|
+
* to be sorted to the query
|
|
39
|
+
* @param {object} sort - The sort to be set.
|
|
40
|
+
* @returns {Reader} - An instance of the Reader class.
|
|
41
|
+
*/
|
|
42
|
+
Sort(sort: object | any): Reader;
|
|
43
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
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
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
16
|
+
// import FileManager from "../../Storage/FileManager";
|
|
17
|
+
const FolderManager_1 = __importDefault(require("../../Storage/FolderManager"));
|
|
18
|
+
const response_helper_1 = __importDefault(require("../../Helper/response.helper"));
|
|
19
|
+
// import { General } from "../../config/Keys/Keys";
|
|
20
|
+
const Converter_helper_1 = __importDefault(require("../../Helper/Converter.helper"));
|
|
21
|
+
const FileManager_1 = __importDefault(require("../../Storage/FileManager"));
|
|
22
|
+
/**
|
|
23
|
+
* Class representing a read operation.
|
|
24
|
+
*/
|
|
25
|
+
class Reader {
|
|
26
|
+
/**
|
|
27
|
+
* Creates an instance of Read.
|
|
28
|
+
* @param {string} collectionName - The name of the collection.
|
|
29
|
+
* @param {string | any} path - The data to be read.
|
|
30
|
+
*/
|
|
31
|
+
constructor(collectionName, path, baseQuery, isEncrypted = false) {
|
|
32
|
+
this.collectionName = collectionName;
|
|
33
|
+
this.path = path;
|
|
34
|
+
this.limit = 10;
|
|
35
|
+
this.skip = 0;
|
|
36
|
+
this.isEncrypted = isEncrypted;
|
|
37
|
+
this.sort = {};
|
|
38
|
+
this.baseQuery = baseQuery;
|
|
39
|
+
this.Converter = new Converter_helper_1.default();
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Reads the data from a file.
|
|
43
|
+
* @returns {Promise<any>} A promise that resolves with the response of the read operation.
|
|
44
|
+
*/
|
|
45
|
+
exac(callback) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
try {
|
|
48
|
+
// Check if Directory Locked or not
|
|
49
|
+
const isLocked = yield new FolderManager_1.default().IsDirectoryLocked(this.path);
|
|
50
|
+
if ("data" in isLocked) {
|
|
51
|
+
if (isLocked.data == false) {
|
|
52
|
+
// Read List the data from the file
|
|
53
|
+
const ReadResponse = yield new FolderManager_1.default().ListDirectory(this.path);
|
|
54
|
+
if ("data" in ReadResponse) {
|
|
55
|
+
return new response_helper_1.default().Success(ReadResponse.data);
|
|
56
|
+
}
|
|
57
|
+
return new response_helper_1.default().Error("Failed to read directory");
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
const unlockResponse = yield new FolderManager_1.default().UnlockDirectory(this.path);
|
|
61
|
+
if ("data" in unlockResponse) {
|
|
62
|
+
// Read List the data from the file
|
|
63
|
+
const ReadResponse = yield new FolderManager_1.default().ListDirectory(this.path);
|
|
64
|
+
if ("data" in ReadResponse) {
|
|
65
|
+
const DataFilesList = ReadResponse.data;
|
|
66
|
+
console.log("DataFilesList", DataFilesList);
|
|
67
|
+
for (let i = 0; i < DataFilesList.length; i++) {
|
|
68
|
+
const ReadFileResponse = yield new FileManager_1.default().ReadFile(`${this.path}/${DataFilesList[i]}`);
|
|
69
|
+
if ("data" in ReadFileResponse) {
|
|
70
|
+
console.log("readed data", ReadFileResponse.data);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return new response_helper_1.default().Error("Failed to read directory");
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
return new response_helper_1.default().Error("Failed to unlock directory");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
return new response_helper_1.default().Error(isLocked);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
return new response_helper_1.default().Error(error);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* set limit to the query
|
|
92
|
+
* @param {number} limit - The limit to be set.
|
|
93
|
+
* @returns {Reader} - An instance of the Reader class.
|
|
94
|
+
*/
|
|
95
|
+
Limit(limit) {
|
|
96
|
+
this.limit = limit;
|
|
97
|
+
return this;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* to be skipped to the query
|
|
101
|
+
* @param {number} skip - The skip to be set.
|
|
102
|
+
* @returns {Reader} - An instance of the Reader class.
|
|
103
|
+
*/
|
|
104
|
+
Skip(skip) {
|
|
105
|
+
this.baseQuery.skip = skip;
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* to be sorted to the query
|
|
110
|
+
* @param {object} sort - The sort to be set.
|
|
111
|
+
* @returns {Reader} - An instance of the Reader class.
|
|
112
|
+
*/
|
|
113
|
+
Sort(sort) {
|
|
114
|
+
this.sort = sort;
|
|
115
|
+
return this;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
exports.default = Reader;
|
|
119
|
+
//# sourceMappingURL=Reader.operation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Reader.operation.js","sourceRoot":"","sources":["../../../source/Operation/CRUD Operation/Reader.operation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,uDAAuD;AACvD,uDAAuD;AACvD,gFAAwD;AAExD,mFAA0D;AAK1D,oDAAoD;AACpD,qFAAsD;AACtD,4EAAoD;AAEpD;;GAEG;AACH,MAAqB,MAAM;IAUzB;;;;OAIG;IACH,YACE,cAAsB,EACtB,IAAkB,EAClB,SAAuB,EACvB,WAAW,GAAG,KAAK;QAEnB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QACd,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;QACf,IAAI,C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reader from "../CRUD Operation/Reader.operation";
|
|
2
3
|
import { CryptoHelper } from "../../Helper/Crypto.helper";
|
|
3
4
|
/**
|
|
4
5
|
* Represents a collection inside a database.
|
|
@@ -20,4 +21,10 @@ export default class Collection {
|
|
|
20
21
|
* @returns {Promise<any>} - A promise that resolves with the response of the insertion operation.
|
|
21
22
|
*/
|
|
22
23
|
insert(data: object | any): Promise<SuccessInterface | ErrorInterface | undefined>;
|
|
24
|
+
/**
|
|
25
|
+
* Reads a document from the collection.
|
|
26
|
+
* @param {object} query - The query to be executed
|
|
27
|
+
* @returns {Reader} - An instance of the Reader class.
|
|
28
|
+
*/
|
|
29
|
+
query(query: object | any): Reader;
|
|
23
30
|
}
|
|
@@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const Create_operation_1 = __importDefault(require("../CRUD Operation/Create.operation"));
|
|
16
|
+
const Reader_operation_1 = __importDefault(require("../CRUD Operation/Reader.operation"));
|
|
16
17
|
const outers_1 = require("outers");
|
|
17
18
|
// Validator
|
|
18
19
|
const validator_models_1 = __importDefault(require("../../Models/validator.models"));
|
|
@@ -63,6 +64,19 @@ class Collection {
|
|
|
63
64
|
return yield this.Insertion.Save(data);
|
|
64
65
|
});
|
|
65
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Reads a document from the collection.
|
|
69
|
+
* @param {object} query - The query to be executed
|
|
70
|
+
* @returns {Reader} - An instance of the Reader class.
|
|
71
|
+
*/
|
|
72
|
+
query(query) {
|
|
73
|
+
// Check if documentId is empty or not
|
|
74
|
+
if (!query) {
|
|
75
|
+
throw new Error("Query cannot be empty");
|
|
76
|
+
}
|
|
77
|
+
// Read the data
|
|
78
|
+
return new Reader_operation_1.default(this.name, this.path, query, this.isEncrypted);
|
|
79
|
+
}
|
|
66
80
|
}
|
|
67
81
|
exports.default = Collection;
|
|
68
82
|
//# sourceMappingURL=collection.operation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection.operation.js","sourceRoot":"","sources":["../../../source/Operation/Collection/collection.operation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAKA,0FAA2D;AAC3D,mCAAiC;AACjC,YAAY;AACZ,qFAA4D;AAG5D,YAAY;AACZ,qFAAsD;AAEtD;;GAEG;AACH,MAAqB,UAAU;IAW7B,YACE,IAAY,EACZ,IAAY,EACZ,KAAmB,EACnB,WAAW,GAAG,KAAK,EACnB,cAA6B;QAE7B,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,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAC1C,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;YAC1C,CAAC;YAED,oCAAoC;YACpC,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC7B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;YAC7C,CAAC;YAED,oBAAoB;YACpB,MAAM,SAAS,GAAG,MAAM,IAAA,0BAAe,EAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAE3D,IAAI,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,EAAE,CAAC;gBACvB,gBAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;gBACnD,OAAO;YACT,CAAC;YAED,wCAAwC;YACxC,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;gBAC5C,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;YAC1E,CAAC;YAED,gBAAgB;YAChB,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzC,CAAC;KAAA;CACF;
|
|
1
|
+
{"version":3,"file":"collection.operation.js","sourceRoot":"","sources":["../../../source/Operation/Collection/collection.operation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAKA,0FAA2D;AAC3D,0FAAwD;AACxD,mCAAiC;AACjC,YAAY;AACZ,qFAA4D;AAG5D,YAAY;AACZ,qFAAsD;AAEtD;;GAEG;AACH,MAAqB,UAAU;IAW7B,YACE,IAAY,EACZ,IAAY,EACZ,KAAmB,EACnB,WAAW,GAAG,KAAK,EACnB,cAA6B;QAE7B,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,SAAS,GAAG,IAAI,I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M,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IACnE,CAAC;CACF;AA/ED,6BA+EC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "axiodb",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.10",
|
|
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",
|