axiodb 1.3.8 → 1.4.1
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/lib/Models/validator.models.d.ts +2 -1
- package/lib/Models/validator.models.js +21 -8
- package/lib/Models/validator.models.js.map +1 -1
- package/lib/Operation/CRUD Operation/Create.operation.d.ts +1 -1
- package/lib/Operation/CRUD Operation/Create.operation.js +4 -2
- package/lib/Operation/CRUD Operation/Create.operation.js.map +1 -1
- package/lib/Operation/CRUD Operation/Update.operation.d.ts +87 -1
- package/lib/Operation/CRUD Operation/Update.operation.js +444 -2
- package/lib/Operation/CRUD Operation/Update.operation.js.map +1 -1
- package/lib/Operation/Collection/collection.operation.d.ts +3 -2
- package/lib/Operation/Collection/collection.operation.js +10 -6
- package/lib/Operation/Collection/collection.operation.js.map +1 -1
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ import { Schema } from "joi";
|
|
|
4
4
|
*
|
|
5
5
|
* @param dataSchema - The Joi schema to validate against.
|
|
6
6
|
* @param data - The data to be validated.
|
|
7
|
+
* @param isUpdate - A boolean flag to indicate if the data is being validated for an update operation.
|
|
7
8
|
* @returns A promise that resolves with the validated data if validation is successful, or rejects with a validation error.
|
|
8
9
|
*/
|
|
9
|
-
export default function schemaValidate(dataSchema: Schema, data: any): Promise<any>;
|
|
10
|
+
export default function schemaValidate(dataSchema: Schema, data: any, isUpdate?: boolean): Promise<any>;
|
|
@@ -20,17 +20,30 @@ const joi_1 = __importDefault(require("joi")); // Ensure to import Joi correctly
|
|
|
20
20
|
*
|
|
21
21
|
* @param dataSchema - The Joi schema to validate against.
|
|
22
22
|
* @param data - The data to be validated.
|
|
23
|
+
* @param isUpdate - A boolean flag to indicate if the data is being validated for an update operation.
|
|
23
24
|
* @returns A promise that resolves with the validated data if validation is successful, or rejects with a validation error.
|
|
24
25
|
*/
|
|
25
|
-
function schemaValidate(
|
|
26
|
-
return __awaiter(this,
|
|
27
|
-
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
function schemaValidate(dataSchema_1, data_1) {
|
|
27
|
+
return __awaiter(this, arguments, void 0, function* (dataSchema, data, isUpdate = false) {
|
|
28
|
+
if (isUpdate) {
|
|
29
|
+
// For update operations, we allow partial data
|
|
30
|
+
try {
|
|
31
|
+
// Use Joi.object() correctly to wrap the schema and validate data.
|
|
32
|
+
const joiSchema = joi_1.default.object(dataSchema).unknown(true); // Converts the provided schema to a Joi object schema
|
|
33
|
+
return yield joiSchema.validateAsync(data); // Validate the actual data against the schema
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
return error;
|
|
37
|
+
}
|
|
31
38
|
}
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
else {
|
|
40
|
+
// For create operations, we require all data fields
|
|
41
|
+
try {
|
|
42
|
+
return yield dataSchema.validateAsync(data); // Validate the actual data against the schema
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
return error;
|
|
46
|
+
}
|
|
34
47
|
}
|
|
35
48
|
});
|
|
36
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator.models.js","sourceRoot":"","sources":["../../source/Models/validator.models.ts"],"names":[],"mappings":";;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"validator.models.js","sourceRoot":"","sources":["../../source/Models/validator.models.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAWA,iCAsBC;AAjCD,uDAAuD;AACvD,8CAAkC,CAAC,iCAAiC;AAEpE;;;;;;;GAOG;AACH,SAA8B,cAAc;yDAC1C,UAAkB,EAClB,IAAS,EACT,QAAQ,GAAG,KAAK;QAEhB,IAAI,QAAQ,EAAE,CAAC;YACb,+CAA+C;YAC/C,IAAI,CAAC;gBACH,mEAAmE;gBACnE,MAAM,SAAS,GAAG,aAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,sDAAsD;gBAC9G,OAAO,MAAM,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,8CAA8C;YAC5F,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;aAAM,CAAC;YACN,oDAAoD;YACpD,IAAI,CAAC;gBACH,OAAO,MAAM,UAAU,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,8CAA8C;YAC7F,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;IACH,CAAC;CAAA"}
|
|
@@ -16,7 +16,7 @@ export default class Insertion {
|
|
|
16
16
|
* Saves the data to a file.
|
|
17
17
|
* @returns {Promise<any>} A promise that resolves with the response of the save operation.
|
|
18
18
|
*/
|
|
19
|
-
Save(data: object | any): Promise<SuccessInterface | ErrorInterface>;
|
|
19
|
+
Save(data: object | any, ExistingdocumentId?: string): Promise<SuccessInterface | ErrorInterface>;
|
|
20
20
|
/**
|
|
21
21
|
* Generates a unique document ID.
|
|
22
22
|
* @returns {Promise<string>} A promise that resolves with a unique document ID.
|
|
@@ -37,10 +37,12 @@ class Insertion {
|
|
|
37
37
|
* Saves the data to a file.
|
|
38
38
|
* @returns {Promise<any>} A promise that resolves with the response of the save operation.
|
|
39
39
|
*/
|
|
40
|
-
Save(data) {
|
|
40
|
+
Save(data, ExistingdocumentId) {
|
|
41
41
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
42
|
try {
|
|
43
|
-
const documentId =
|
|
43
|
+
const documentId = ExistingdocumentId === undefined
|
|
44
|
+
? yield this.generateUniqueDocumentId()
|
|
45
|
+
: ExistingdocumentId;
|
|
44
46
|
const filePath = `${this.path}/.${documentId}${Keys_1.General.DBMS_File_EXT}`;
|
|
45
47
|
// Check if Directory Locked or not
|
|
46
48
|
const isLocked = yield new FolderManager_1.default().IsDirectoryLocked(this.path);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Create.operation.js","sourceRoot":"","sources":["../../../source/Operation/CRUD Operation/Create.operation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,uDAAuD;AACvD,4EAAoD;AACpD,gFAAwD;AAExD,mCAAoC;AACpC,mFAA0D;AAK1D,iDAAiD;AACjD,qFAAsD;AAEtD;;GAEG;AACH,MAAqB,SAAS;IAK5B;;;;OAIG;IACH,YAAY,cAAsB,EAAE,IAAkB;QACpD,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,IAAI,0BAAS,EAAE,CAAC;IACnC,CAAC;IAED;;;OAGG;IACU,IAAI,CACf,IAAkB;;
|
|
1
|
+
{"version":3,"file":"Create.operation.js","sourceRoot":"","sources":["../../../source/Operation/CRUD Operation/Create.operation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,uDAAuD;AACvD,4EAAoD;AACpD,gFAAwD;AAExD,mCAAoC;AACpC,mFAA0D;AAK1D,iDAAiD;AACjD,qFAAsD;AAEtD;;GAEG;AACH,MAAqB,SAAS;IAK5B;;;;OAIG;IACH,YAAY,cAAsB,EAAE,IAAkB;QACpD,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,IAAI,0BAAS,EAAE,CAAC;IACnC,CAAC;IAED;;;OAGG;IACU,IAAI,CACf,IAAkB,EAClB,kBAA2B;;YAE3B,IAAI,CAAC;gBACH,MAAM,UAAU,GACd,kBAAkB,KAAK,SAAS;oBAC9B,CAAC,CAAC,MAAM,IAAI,CAAC,wBAAwB,EAAE;oBACvC,CAAC,CAAC,kBAAkB,CAAC;gBACzB,MAAM,QAAQ,GAAG,GAAG,IAAI,CAAC,IAAI,KAAK,UAAU,GAAG,cAAO,CAAC,aAAa,EAAE,CAAC;gBAEvE,mCAAmC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AAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;gBACzD,MAAM,QAAQ,GAAG,MAAM,IAAI,qBAAW,EAAE,CAAC,UAAU,CACjD,GAAG,IAAI,CAAC,IAAI,IAAI,EAAE,GAAG,cAAO,CAAC,aAAa,EAAE,CAC7C,CAAC;gBACF,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC;YAC5B,CAAC,QAAQ,OAAO,EAAE;YAElB,OAAO,EAAE,CAAC;QACZ,CAAC;KAAA;CACF;AAlHD,4BAkHC"}
|
|
@@ -1,3 +1,89 @@
|
|
|
1
|
+
import { ErrorInterface, SuccessInterface } from "../../config/Interfaces/Helper/response.helper.interface";
|
|
1
2
|
export default class UpdateOperation {
|
|
2
|
-
|
|
3
|
+
protected readonly collectionName: string;
|
|
4
|
+
private readonly baseQuery;
|
|
5
|
+
private readonly path;
|
|
6
|
+
private readonly isEncrypted;
|
|
7
|
+
private readonly encryptionKey;
|
|
8
|
+
private readonly ResponseHelper;
|
|
9
|
+
private readonly cryptoInstance?;
|
|
10
|
+
private readonly Converter;
|
|
11
|
+
private allDataWithFileName;
|
|
12
|
+
private sort;
|
|
13
|
+
private updatedAt;
|
|
14
|
+
private schema;
|
|
15
|
+
private readonly Insertion;
|
|
16
|
+
constructor(collectionName: string, path: string, baseQuery: object | any, schema: object | any, isEncrypted?: boolean, encryptionKey?: string);
|
|
17
|
+
/**
|
|
18
|
+
* Updates a single document that matches the base query.
|
|
19
|
+
*
|
|
20
|
+
* This method performs the following operations:
|
|
21
|
+
* 1. Searches for documents matching the base query
|
|
22
|
+
* 2. If documents are found, selects the first document (or first after sorting if sort criteria are provided)
|
|
23
|
+
* 3. Deletes the existing document file
|
|
24
|
+
* 4. Inserts a new file with updated data using the same document ID
|
|
25
|
+
*
|
|
26
|
+
* @param newData - The new data to replace the existing document
|
|
27
|
+
* @returns A Promise resolving to:
|
|
28
|
+
* - Success with updated data and previous data if successful
|
|
29
|
+
* - Error if any step fails
|
|
30
|
+
* @throws May throw errors during file operations or data processing
|
|
31
|
+
*/
|
|
32
|
+
UpdateOne(newData: object | any): Promise<SuccessInterface | ErrorInterface>;
|
|
33
|
+
/**
|
|
34
|
+
* Updates multiple documents that match the base query.
|
|
35
|
+
*
|
|
36
|
+
* This method performs the following operations:
|
|
37
|
+
* 1. Searches for documents matching the base query
|
|
38
|
+
* 2. Deletes the existing documents
|
|
39
|
+
* 3. Inserts new files with updated data for each document
|
|
40
|
+
*
|
|
41
|
+
* @param newData - The new data to replace the existing documents
|
|
42
|
+
* @returns A Promise resolving to:
|
|
43
|
+
* - Success with updated data and previous data if successful
|
|
44
|
+
* - Error if any step fails
|
|
45
|
+
* @throws May throw errors during file operations or data processing
|
|
46
|
+
*/
|
|
47
|
+
UpdateMany(newData: object | any): Promise<SuccessInterface | ErrorInterface>;
|
|
48
|
+
/**
|
|
49
|
+
* to be sorted to the query this.createdAt = new Date().toISOString();
|
|
50
|
+
this.updatedAt = this.createdAt; // Initially updatedAt is same as createdAt
|
|
51
|
+
* @param {object} sort - The sort to be set.
|
|
52
|
+
* @returns {DeleteOperation} - An instance of the DeleteOperation class.
|
|
53
|
+
*/
|
|
54
|
+
Sort(sort: object | any): UpdateOperation;
|
|
55
|
+
/**
|
|
56
|
+
* Loads all buffer raw data from the specified directory.
|
|
57
|
+
*
|
|
58
|
+
* This method performs the following steps:
|
|
59
|
+
* 1. Checks if the directory is locked.
|
|
60
|
+
* 2. If the directory is not locked, it lists all files in the directory.
|
|
61
|
+
* 3. Reads each file and decrypts the data if encryption is enabled.
|
|
62
|
+
* 4. Stores the decrypted data in the `AllData` array.
|
|
63
|
+
* 5. If the directory is locked, it unlocks the directory, reads the files, and then locks the directory again.
|
|
64
|
+
*
|
|
65
|
+
* @returns {Promise<SuccessInterface | ErrorInterface>} A promise that resolves to a success or error response.
|
|
66
|
+
*
|
|
67
|
+
* @throws {Error} Throws an error if any operation fails.
|
|
68
|
+
*/
|
|
69
|
+
private LoadAllBufferRawData;
|
|
70
|
+
/**
|
|
71
|
+
* Deletes a file from the specified path.
|
|
72
|
+
*
|
|
73
|
+
* This method checks if the directory is locked before attempting to delete the file.
|
|
74
|
+
* If the directory is locked, it tries to unlock it, delete the file, and then lock it again.
|
|
75
|
+
*
|
|
76
|
+
* @param fileName - The name of the file to be deleted
|
|
77
|
+
* @returns A response object indicating success or failure
|
|
78
|
+
* Success response: { status: true, message: "File deleted successfully" }
|
|
79
|
+
* Error response: { status: false, message: <error message> }
|
|
80
|
+
* @private
|
|
81
|
+
*/
|
|
82
|
+
private deleteFileUpdate;
|
|
83
|
+
/**
|
|
84
|
+
* Inserts a document into the collection.
|
|
85
|
+
* @param {object} data - The data to be inserted.
|
|
86
|
+
* @returns {Promise<any>} - A promise that resolves with the response of the insertion operation.
|
|
87
|
+
*/
|
|
88
|
+
insertUpdate(data: object | any, ExistingdocumentId?: string): Promise<SuccessInterface | ErrorInterface>;
|
|
3
89
|
}
|
|
@@ -1,8 +1,450 @@
|
|
|
1
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
|
+
};
|
|
2
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const Converter_helper_1 = __importDefault(require("../../Helper/Converter.helper"));
|
|
16
|
+
const Crypto_helper_1 = require("../../Helper/Crypto.helper");
|
|
17
|
+
const response_helper_1 = __importDefault(require("../../Helper/response.helper"));
|
|
18
|
+
const DataTypes_models_1 = require("../../Models/DataTypes.models");
|
|
19
|
+
const FileManager_1 = __importDefault(require("../../Storage/FileManager"));
|
|
20
|
+
const FolderManager_1 = __importDefault(require("../../Storage/FolderManager"));
|
|
21
|
+
const HashMapSearch_utils_1 = __importDefault(require("../../utils/HashMapSearch.utils"));
|
|
22
|
+
const SortData_utils_1 = __importDefault(require("../../utils/SortData.utils"));
|
|
23
|
+
const outers_1 = require("outers");
|
|
24
|
+
// Validator
|
|
25
|
+
const validator_models_1 = __importDefault(require("../../Models/validator.models"));
|
|
26
|
+
const Create_operation_1 = __importDefault(require("./Create.operation"));
|
|
3
27
|
class UpdateOperation {
|
|
4
|
-
constructor() {
|
|
5
|
-
|
|
28
|
+
constructor(collectionName, path, baseQuery, schema, isEncrypted = false, encryptionKey) {
|
|
29
|
+
this.allDataWithFileName = [];
|
|
30
|
+
this.collectionName = collectionName;
|
|
31
|
+
this.path = path;
|
|
32
|
+
this.baseQuery = baseQuery;
|
|
33
|
+
this.isEncrypted = isEncrypted;
|
|
34
|
+
this.encryptionKey = encryptionKey;
|
|
35
|
+
this.updatedAt = new Date().toISOString();
|
|
36
|
+
this.sort = {};
|
|
37
|
+
this.schema = schema;
|
|
38
|
+
this.Insertion = new Create_operation_1.default(this.collectionName, this.path);
|
|
39
|
+
this.ResponseHelper = new response_helper_1.default();
|
|
40
|
+
this.Converter = new Converter_helper_1.default();
|
|
41
|
+
if (this.isEncrypted && this.encryptionKey) {
|
|
42
|
+
this.cryptoInstance = new Crypto_helper_1.CryptoHelper(this.encryptionKey);
|
|
43
|
+
}
|
|
44
|
+
this.allDataWithFileName = []; // To store all data with file name
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Updates a single document that matches the base query.
|
|
48
|
+
*
|
|
49
|
+
* This method performs the following operations:
|
|
50
|
+
* 1. Searches for documents matching the base query
|
|
51
|
+
* 2. If documents are found, selects the first document (or first after sorting if sort criteria are provided)
|
|
52
|
+
* 3. Deletes the existing document file
|
|
53
|
+
* 4. Inserts a new file with updated data using the same document ID
|
|
54
|
+
*
|
|
55
|
+
* @param newData - The new data to replace the existing document
|
|
56
|
+
* @returns A Promise resolving to:
|
|
57
|
+
* - Success with updated data and previous data if successful
|
|
58
|
+
* - Error if any step fails
|
|
59
|
+
* @throws May throw errors during file operations or data processing
|
|
60
|
+
*/
|
|
61
|
+
UpdateOne(newData) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
try {
|
|
64
|
+
// Insert the updatedAt field in schema & data
|
|
65
|
+
this.schema.updatedAt = DataTypes_models_1.SchemaTypes.date().required();
|
|
66
|
+
newData.updatedAt = new Date().toISOString();
|
|
67
|
+
// check if the data is an object or not
|
|
68
|
+
if (typeof newData !== "object") {
|
|
69
|
+
throw new Error("Data must be an object.");
|
|
70
|
+
}
|
|
71
|
+
// delete the extra fields from the schema if not present in the data
|
|
72
|
+
for (const key in newData) {
|
|
73
|
+
if (this.schema[key]) {
|
|
74
|
+
const newSchema = {
|
|
75
|
+
[key]: this.schema[key],
|
|
76
|
+
};
|
|
77
|
+
this.schema = newSchema;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// Validate the data
|
|
81
|
+
const validator = yield (0, validator_models_1.default)(this.schema, newData, false);
|
|
82
|
+
if (validator === null || validator === void 0 ? void 0 : validator.details) {
|
|
83
|
+
outers_1.Console.red("Validation Error", validator.details);
|
|
84
|
+
return this.ResponseHelper.Error(validator.details);
|
|
85
|
+
}
|
|
86
|
+
const ReadResponse = yield this.LoadAllBufferRawData();
|
|
87
|
+
if ("data" in ReadResponse) {
|
|
88
|
+
const SearchedData = yield new HashMapSearch_utils_1.default(ReadResponse.data).find(this.baseQuery, "data");
|
|
89
|
+
if (SearchedData.length === 0) {
|
|
90
|
+
return this.ResponseHelper.Error("No data found with the specified query");
|
|
91
|
+
}
|
|
92
|
+
let selectedFirstData = SearchedData[0]; // Select the first data
|
|
93
|
+
let fileName = selectedFirstData === null || selectedFirstData === void 0 ? void 0 : selectedFirstData.fileName; // Get the file name
|
|
94
|
+
const documentOldData = selectedFirstData.data; // Get the old data
|
|
95
|
+
// Sort the data if sort is provided then select the first data for deletion
|
|
96
|
+
if (Object.keys(this.sort).length === 0) {
|
|
97
|
+
selectedFirstData = SearchedData[0]; // Select the first data
|
|
98
|
+
fileName = selectedFirstData === null || selectedFirstData === void 0 ? void 0 : selectedFirstData.fileName; // Get the file name
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
const Sorter = new SortData_utils_1.default(SearchedData, this.sort);
|
|
102
|
+
const SortedData = yield Sorter.sort("data"); // Sort the data
|
|
103
|
+
selectedFirstData = SortedData[0]; // Select the first data
|
|
104
|
+
fileName = selectedFirstData === null || selectedFirstData === void 0 ? void 0 : selectedFirstData.fileName; // Get the file name
|
|
105
|
+
}
|
|
106
|
+
const documentId = fileName.startsWith(".")
|
|
107
|
+
? fileName.slice(1).split(".")[0]
|
|
108
|
+
: fileName.split(".")[0];
|
|
109
|
+
// Update All new Fields in the old data
|
|
110
|
+
for (const key in newData) {
|
|
111
|
+
documentOldData[key] = newData[key];
|
|
112
|
+
// also change the updatedAt field
|
|
113
|
+
documentOldData.updatedAt = this.updatedAt;
|
|
114
|
+
}
|
|
115
|
+
// Delete the file
|
|
116
|
+
const deleteResponse = yield this.deleteFileUpdate(fileName);
|
|
117
|
+
if ("data" in deleteResponse) {
|
|
118
|
+
// Insert the new Data in the file
|
|
119
|
+
const InsertResponse = yield this.insertUpdate(documentOldData, documentId);
|
|
120
|
+
if ("data" in InsertResponse) {
|
|
121
|
+
return this.ResponseHelper.Success({
|
|
122
|
+
message: "Data updated successfully",
|
|
123
|
+
newData: newData,
|
|
124
|
+
previousData: selectedFirstData.data,
|
|
125
|
+
documentId: documentId,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
return this.ResponseHelper.Error("Failed to insert data");
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
return this.ResponseHelper.Error("Failed to delete file");
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
return this.ResponseHelper.Error("Failed to read raw data");
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
return this.ResponseHelper.Error("Failed to update data");
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Updates multiple documents that match the base query.
|
|
147
|
+
*
|
|
148
|
+
* This method performs the following operations:
|
|
149
|
+
* 1. Searches for documents matching the base query
|
|
150
|
+
* 2. Deletes the existing documents
|
|
151
|
+
* 3. Inserts new files with updated data for each document
|
|
152
|
+
*
|
|
153
|
+
* @param newData - The new data to replace the existing documents
|
|
154
|
+
* @returns A Promise resolving to:
|
|
155
|
+
* - Success with updated data and previous data if successful
|
|
156
|
+
* - Error if any step fails
|
|
157
|
+
* @throws May throw errors during file operations or data processing
|
|
158
|
+
*/
|
|
159
|
+
UpdateMany(newData) {
|
|
160
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
+
try {
|
|
162
|
+
// Insert the updatedAt field in schema & data
|
|
163
|
+
this.schema.updatedAt = DataTypes_models_1.SchemaTypes.date().required();
|
|
164
|
+
newData.updatedAt = new Date().toISOString();
|
|
165
|
+
// check if the data is an object or not
|
|
166
|
+
if (typeof newData !== "object") {
|
|
167
|
+
throw new Error("Data must be an object.");
|
|
168
|
+
}
|
|
169
|
+
// delete the extra fields from the schema if not present in the data
|
|
170
|
+
for (const key in newData) {
|
|
171
|
+
if (this.schema[key]) {
|
|
172
|
+
const newSchema = {
|
|
173
|
+
[key]: this.schema[key],
|
|
174
|
+
};
|
|
175
|
+
this.schema = newSchema;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
// Validate the data
|
|
179
|
+
const validator = yield (0, validator_models_1.default)(this.schema, newData, true);
|
|
180
|
+
if (validator === null || validator === void 0 ? void 0 : validator.details) {
|
|
181
|
+
outers_1.Console.red("Validation Error", validator.details);
|
|
182
|
+
return this.ResponseHelper.Error(validator.details);
|
|
183
|
+
}
|
|
184
|
+
const ReadResponse = yield this.LoadAllBufferRawData();
|
|
185
|
+
if ("data" in ReadResponse) {
|
|
186
|
+
const SearchedData = yield new HashMapSearch_utils_1.default(ReadResponse.data).find(this.baseQuery, "data");
|
|
187
|
+
if (SearchedData.length === 0) {
|
|
188
|
+
return this.ResponseHelper.Error("No data found with the specified query");
|
|
189
|
+
}
|
|
190
|
+
const documentIds = [];
|
|
191
|
+
for (let i = 0; i < SearchedData.length; i++) {
|
|
192
|
+
let selectedData = SearchedData[i]; // Select the first data
|
|
193
|
+
let fileName = selectedData === null || selectedData === void 0 ? void 0 : selectedData.fileName; // Get the file name
|
|
194
|
+
const documentOldData = selectedData.data; // Get the old data
|
|
195
|
+
// Sort the data if sort is provided then select the first data for deletion
|
|
196
|
+
if (Object.keys(this.sort).length === 0) {
|
|
197
|
+
selectedData = SearchedData[i]; // Select the first data
|
|
198
|
+
fileName = selectedData === null || selectedData === void 0 ? void 0 : selectedData.fileName; // Get the file name
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
const Sorter = new SortData_utils_1.default(SearchedData, this.sort);
|
|
202
|
+
const SortedData = yield Sorter.sort("data"); // Sort the data
|
|
203
|
+
selectedData = SortedData[i]; // Select the first data
|
|
204
|
+
fileName = selectedData === null || selectedData === void 0 ? void 0 : selectedData.fileName; // Get the file name
|
|
205
|
+
}
|
|
206
|
+
const documentId = fileName.startsWith(".")
|
|
207
|
+
? fileName.slice(1).split(".")[0]
|
|
208
|
+
: fileName.split(".")[0];
|
|
209
|
+
documentIds.push(documentId);
|
|
210
|
+
// Update All new Fields in the old data
|
|
211
|
+
for (const key in newData) {
|
|
212
|
+
documentOldData[key] = newData[key];
|
|
213
|
+
// also change the updatedAt field
|
|
214
|
+
documentOldData.updatedAt = this.updatedAt;
|
|
215
|
+
}
|
|
216
|
+
// Delete the file
|
|
217
|
+
const deleteResponse = yield this.deleteFileUpdate(fileName);
|
|
218
|
+
if ("data" in deleteResponse) {
|
|
219
|
+
// Insert the new Data in the file
|
|
220
|
+
const InsertResponse = yield this.insertUpdate(documentOldData, documentId);
|
|
221
|
+
if ("data" in InsertResponse) {
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
return this.ResponseHelper.Error("Failed to insert data");
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
return this.ResponseHelper.Error("Failed to delete file");
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return this.ResponseHelper.Success({
|
|
233
|
+
message: "Data updated successfully",
|
|
234
|
+
newData: newData,
|
|
235
|
+
documentIds: documentIds,
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
return this.ResponseHelper.Error("Failed to read raw data");
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
catch (error) {
|
|
243
|
+
return this.ResponseHelper.Error("Failed to update data");
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* to be sorted to the query this.createdAt = new Date().toISOString();
|
|
249
|
+
this.updatedAt = this.createdAt; // Initially updatedAt is same as createdAt
|
|
250
|
+
* @param {object} sort - The sort to be set.
|
|
251
|
+
* @returns {DeleteOperation} - An instance of the DeleteOperation class.
|
|
252
|
+
*/
|
|
253
|
+
Sort(sort) {
|
|
254
|
+
this.sort = sort;
|
|
255
|
+
return this;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Loads all buffer raw data from the specified directory.
|
|
259
|
+
*
|
|
260
|
+
* This method performs the following steps:
|
|
261
|
+
* 1. Checks if the directory is locked.
|
|
262
|
+
* 2. If the directory is not locked, it lists all files in the directory.
|
|
263
|
+
* 3. Reads each file and decrypts the data if encryption is enabled.
|
|
264
|
+
* 4. Stores the decrypted data in the `AllData` array.
|
|
265
|
+
* 5. If the directory is locked, it unlocks the directory, reads the files, and then locks the directory again.
|
|
266
|
+
*
|
|
267
|
+
* @returns {Promise<SuccessInterface | ErrorInterface>} A promise that resolves to a success or error response.
|
|
268
|
+
*
|
|
269
|
+
* @throws {Error} Throws an error if any operation fails.
|
|
270
|
+
*/
|
|
271
|
+
LoadAllBufferRawData() {
|
|
272
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
273
|
+
try {
|
|
274
|
+
// Check if Directory Locked or not
|
|
275
|
+
const isLocked = yield new FolderManager_1.default().IsDirectoryLocked(this.path);
|
|
276
|
+
if ("data" in isLocked) {
|
|
277
|
+
// If Directory is not locked
|
|
278
|
+
if (isLocked.data === false) {
|
|
279
|
+
// Read List the data from the file
|
|
280
|
+
const ReadResponse = yield new FolderManager_1.default().ListDirectory(this.path);
|
|
281
|
+
if ("data" in ReadResponse) {
|
|
282
|
+
// Store all files in DataFilesList
|
|
283
|
+
const DataFilesList = ReadResponse.data;
|
|
284
|
+
// Read all files from the directory
|
|
285
|
+
for (let i = 0; i < DataFilesList.length; i++) {
|
|
286
|
+
const ReadFileResponse = yield new FileManager_1.default().ReadFile(`${this.path}/${DataFilesList[i]}`);
|
|
287
|
+
// Check if the file is read successfully or not
|
|
288
|
+
if ("data" in ReadFileResponse) {
|
|
289
|
+
if (this.isEncrypted === true && this.cryptoInstance) {
|
|
290
|
+
// Decrypt the data if crypto is enabled
|
|
291
|
+
const ContentResponse = yield this.cryptoInstance.decrypt(this.Converter.ToObject(ReadFileResponse.data));
|
|
292
|
+
// Store all Decrypted Data in AllData
|
|
293
|
+
this.allDataWithFileName.push({
|
|
294
|
+
fileName: DataFilesList[i],
|
|
295
|
+
data: this.Converter.ToObject(ContentResponse),
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
this.allDataWithFileName.push({
|
|
300
|
+
fileName: DataFilesList[i],
|
|
301
|
+
data: this.Converter.ToObject(ReadFileResponse.data),
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
return this.ResponseHelper.Error(`Failed to read file: ${DataFilesList[i]}`);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return this.ResponseHelper.Success(this.allDataWithFileName);
|
|
310
|
+
}
|
|
311
|
+
return this.ResponseHelper.Error("Failed to read directory");
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
// if Directory is locked then unlock it
|
|
315
|
+
const unlockResponse = yield new FolderManager_1.default().UnlockDirectory(this.path);
|
|
316
|
+
if ("data" in unlockResponse) {
|
|
317
|
+
// Read List the data from the file
|
|
318
|
+
const ReadResponse = yield new FolderManager_1.default().ListDirectory(this.path);
|
|
319
|
+
if ("data" in ReadResponse) {
|
|
320
|
+
// Store all files in DataFilesList
|
|
321
|
+
const DataFilesList = ReadResponse.data;
|
|
322
|
+
// Read all files from the directory
|
|
323
|
+
for (let i = 0; i < DataFilesList.length; i++) {
|
|
324
|
+
const ReadFileResponse = yield new FileManager_1.default().ReadFile(`${this.path}/${DataFilesList[i]}`);
|
|
325
|
+
// Check if the file is read successfully or not
|
|
326
|
+
if ("data" in ReadFileResponse) {
|
|
327
|
+
if (this.isEncrypted === true && this.cryptoInstance) {
|
|
328
|
+
// Decrypt the data if crypto is enabled
|
|
329
|
+
const ContaentResponse = yield this.cryptoInstance.decrypt(this.Converter.ToObject(ReadFileResponse.data));
|
|
330
|
+
// Store all Decrypted Data in AllData
|
|
331
|
+
this.allDataWithFileName.push({
|
|
332
|
+
fileName: DataFilesList[i],
|
|
333
|
+
data: this.Converter.ToObject(ContaentResponse),
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
this.allDataWithFileName.push({
|
|
338
|
+
fileName: DataFilesList[i],
|
|
339
|
+
data: this.Converter.ToObject(ReadFileResponse.data),
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
return this.ResponseHelper.Error(`Failed to read file: ${DataFilesList[i]}`);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
// Lock the directory after reading all files
|
|
348
|
+
const lockResponse = yield new FolderManager_1.default().LockDirectory(this.path);
|
|
349
|
+
if ("data" in lockResponse) {
|
|
350
|
+
return this.ResponseHelper.Success(this.allDataWithFileName);
|
|
351
|
+
}
|
|
352
|
+
else {
|
|
353
|
+
return this.ResponseHelper.Error(`Failed to lock directory: ${this.path}`);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
return this.ResponseHelper.Error(`Failed to read directory: ${this.path}`);
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
return this.ResponseHelper.Error(`Failed to unlock directory: ${this.path}`);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
return this.ResponseHelper.Error(isLocked);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
catch (error) {
|
|
368
|
+
return this.ResponseHelper.Error(error);
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Deletes a file from the specified path.
|
|
374
|
+
*
|
|
375
|
+
* This method checks if the directory is locked before attempting to delete the file.
|
|
376
|
+
* If the directory is locked, it tries to unlock it, delete the file, and then lock it again.
|
|
377
|
+
*
|
|
378
|
+
* @param fileName - The name of the file to be deleted
|
|
379
|
+
* @returns A response object indicating success or failure
|
|
380
|
+
* Success response: { status: true, message: "File deleted successfully" }
|
|
381
|
+
* Error response: { status: false, message: <error message> }
|
|
382
|
+
* @private
|
|
383
|
+
*/
|
|
384
|
+
deleteFileUpdate(fileName) {
|
|
385
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
386
|
+
// Check if Directory Locked or not
|
|
387
|
+
const isLocked = yield new FolderManager_1.default().IsDirectoryLocked(this.path);
|
|
388
|
+
if ("data" in isLocked) {
|
|
389
|
+
// If Directory is not locked
|
|
390
|
+
if (isLocked.data === false) {
|
|
391
|
+
const deleteResponse = yield new FileManager_1.default().DeleteFile(`${this.path}/${fileName}`);
|
|
392
|
+
if ("data" in deleteResponse) {
|
|
393
|
+
return this.ResponseHelper.Success("File deleted successfully");
|
|
394
|
+
}
|
|
395
|
+
else {
|
|
396
|
+
return this.ResponseHelper.Error("Failed to delete file");
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
else {
|
|
400
|
+
const unlockResponse = yield new FolderManager_1.default().UnlockDirectory(this.path);
|
|
401
|
+
if ("data" in unlockResponse) {
|
|
402
|
+
const deleteResponse = yield new FileManager_1.default().DeleteFile(`${this.path}/${fileName}`);
|
|
403
|
+
if ("data" in deleteResponse) {
|
|
404
|
+
const lockResponse = yield new FolderManager_1.default().LockDirectory(this.path);
|
|
405
|
+
if ("data" in lockResponse) {
|
|
406
|
+
return this.ResponseHelper.Success("File deleted successfully");
|
|
407
|
+
}
|
|
408
|
+
else {
|
|
409
|
+
return this.ResponseHelper.Error("Failed to lock directory");
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
else {
|
|
413
|
+
return this.ResponseHelper.Error("Failed to delete file");
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
else {
|
|
417
|
+
return this.ResponseHelper.Error("Failed to unlock directory");
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
else {
|
|
422
|
+
return this.ResponseHelper.Error("Failed to delete file");
|
|
423
|
+
}
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Inserts a document into the collection.
|
|
428
|
+
* @param {object} data - The data to be inserted.
|
|
429
|
+
* @returns {Promise<any>} - A promise that resolves with the response of the insertion operation.
|
|
430
|
+
*/
|
|
431
|
+
insertUpdate(data, ExistingdocumentId) {
|
|
432
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
433
|
+
// Check if data is empty or not
|
|
434
|
+
if (!data) {
|
|
435
|
+
throw new Error("Data cannot be empty");
|
|
436
|
+
}
|
|
437
|
+
// Check if data is an object or not
|
|
438
|
+
if (typeof data !== "object") {
|
|
439
|
+
throw new Error("Data must be an object.");
|
|
440
|
+
}
|
|
441
|
+
// Encrypt the data if crypto is enabled
|
|
442
|
+
if (this.cryptoInstance && this.isEncrypted) {
|
|
443
|
+
data = yield this.cryptoInstance.encrypt(this.Converter.ToString(data));
|
|
444
|
+
}
|
|
445
|
+
// Save the data
|
|
446
|
+
return yield this.Insertion.Save(data, ExistingdocumentId);
|
|
447
|
+
});
|
|
6
448
|
}
|
|
7
449
|
}
|
|
8
450
|
exports.default = UpdateOperation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Update.operation.js","sourceRoot":"","sources":["../../../source/Operation/CRUD Operation/Update.operation.ts"],"names":[],"mappings":";;AAAA,MAAqB,eAAe;IAClC;QACE,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IACjC,CAAC;CACF;AAJD,kCAIC"}
|
|
1
|
+
{"version":3,"file":"Update.operation.js","sourceRoot":"","sources":["../../../source/Operation/CRUD Operation/Update.operation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAMA,qFAAsD;AACtD,8DAA0D;AAC1D,mFAA0D;AAC1D,oEAA4D;AAC5D,4EAAoD;AACpD,gFAAwD;AACxD,0FAA4D;AAC5D,gFAAiD;AACjD,mCAAiC;AACjC,YAAY;AACZ,qFAA4D;AAC5D,0EAA2C;AAE3C,MAAqB,eAAe;IAgBlC,YACE,cAAsB,EACtB,IAAY,EACZ,SAAuB,EACvB,MAAoB,EACpB,cAAuB,KAAK,EAC5B,aAAsB;QAZhB,wBAAmB,GAAU,EAAE,CAAC;QActC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC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I,CAAC,CAAC,CAAC;YAC1E,CAAC;YAED,gBAAgB;YAChB,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;QAC7D,CAAC;KAAA;CACF;AA9eD,kCA8eC"}
|
|
@@ -2,14 +2,14 @@ import { ErrorInterface, SuccessInterface } from "../../config/Interfaces/Helper
|
|
|
2
2
|
import Reader from "../CRUD Operation/Reader.operation";
|
|
3
3
|
import DeleteOperation from "../CRUD Operation/Delete.operation";
|
|
4
4
|
import { CryptoHelper } from "../../Helper/Crypto.helper";
|
|
5
|
+
import UpdateOperation from "../CRUD Operation/Update.operation";
|
|
5
6
|
/**
|
|
6
7
|
* Represents a collection inside a database.
|
|
7
8
|
*/
|
|
8
9
|
export default class Collection {
|
|
9
10
|
private readonly name;
|
|
10
11
|
private readonly path;
|
|
11
|
-
private
|
|
12
|
-
updatedAt: string;
|
|
12
|
+
private updatedAt;
|
|
13
13
|
private schema;
|
|
14
14
|
private isEncrypted;
|
|
15
15
|
private cryptoInstance?;
|
|
@@ -43,4 +43,5 @@ export default class Collection {
|
|
|
43
43
|
* ```
|
|
44
44
|
*/
|
|
45
45
|
delete(query: object | any): DeleteOperation;
|
|
46
|
+
update(query: object | any): UpdateOperation;
|
|
46
47
|
}
|
|
@@ -22,6 +22,7 @@ const validator_models_1 = __importDefault(require("../../Models/validator.model
|
|
|
22
22
|
// Converter
|
|
23
23
|
const Converter_helper_1 = __importDefault(require("../../Helper/Converter.helper"));
|
|
24
24
|
const DataTypes_models_1 = require("../../Models/DataTypes.models");
|
|
25
|
+
const Update_operation_1 = __importDefault(require("../CRUD Operation/Update.operation"));
|
|
25
26
|
/**
|
|
26
27
|
* Represents a collection inside a database.
|
|
27
28
|
*/
|
|
@@ -33,8 +34,7 @@ class Collection {
|
|
|
33
34
|
this.isEncrypted = isEncrypted;
|
|
34
35
|
this.cryptoInstance = cryptoInstance;
|
|
35
36
|
this.Converter = new Converter_helper_1.default();
|
|
36
|
-
this.
|
|
37
|
-
this.updatedAt = this.createdAt; // Initially updatedAt is same as createdAt
|
|
37
|
+
this.updatedAt = new Date().toISOString();
|
|
38
38
|
this.encryptionKey = encryptionKey;
|
|
39
39
|
// Initialize the Insertion class
|
|
40
40
|
this.Insertion = new Create_operation_1.default(this.name, this.path);
|
|
@@ -54,13 +54,11 @@ class Collection {
|
|
|
54
54
|
if (typeof data !== "object") {
|
|
55
55
|
throw new Error("Data must be an object.");
|
|
56
56
|
}
|
|
57
|
-
// Insert the
|
|
58
|
-
data.createdAt = this.createdAt;
|
|
57
|
+
// Insert the updatedAt field in schema & data
|
|
59
58
|
data.updatedAt = this.updatedAt;
|
|
60
|
-
this.schema.createdAt = DataTypes_models_1.SchemaTypes.date().required();
|
|
61
59
|
this.schema.updatedAt = DataTypes_models_1.SchemaTypes.date().required();
|
|
62
60
|
// Validate the data
|
|
63
|
-
const validator = yield (0, validator_models_1.default)(this.schema, data);
|
|
61
|
+
const validator = yield (0, validator_models_1.default)(this.schema, data, false);
|
|
64
62
|
if (validator === null || validator === void 0 ? void 0 : validator.details) {
|
|
65
63
|
outers_1.Console.red("Validation Error", validator.details);
|
|
66
64
|
return;
|
|
@@ -107,6 +105,12 @@ class Collection {
|
|
|
107
105
|
// Delete the data
|
|
108
106
|
return new Delete_operation_1.default(this.name, this.path, query, this.isEncrypted, this.encryptionKey);
|
|
109
107
|
}
|
|
108
|
+
update(query) {
|
|
109
|
+
if (!query) {
|
|
110
|
+
throw new Error("Query cannot be empty");
|
|
111
|
+
}
|
|
112
|
+
return new Update_operation_1.default(this.name, this.path, query, this.schema, this.isEncrypted, this.encryptionKey);
|
|
113
|
+
}
|
|
110
114
|
}
|
|
111
115
|
exports.default = Collection;
|
|
112
116
|
//# 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,aAAa;AACb,0FAA2D;AAC3D,0FAAwD;AACxD,0FAAiE;AAEjE,mCAAiC;AACjC,YAAY;AACZ,qFAA4D;AAG5D,YAAY;AACZ,qFAAsD;AACtD,oEAA4D;
|
|
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;YAC1C,CAAC;YAED,oCAAoC;YACpC,IA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AAC,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "axiodb",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
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",
|