axiodb 7.33.235 → 8.33.236
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/.dockerignore +73 -0
- package/README.md +9 -1
- package/lib/Services/CRUD Operation/Delete.operation.d.ts +10 -5
- package/lib/Services/CRUD Operation/Delete.operation.js +93 -60
- package/lib/Services/CRUD Operation/Delete.operation.js.map +1 -1
- package/lib/Services/CRUD Operation/Update.operation.d.ts +14 -10
- package/lib/Services/CRUD Operation/Update.operation.js +143 -115
- package/lib/Services/CRUD Operation/Update.operation.js.map +1 -1
- package/package.json +1 -1
- package/.agents/skills/axiodb-development/SKILL.md +0 -284
- package/.claude/SETTINGS.md +0 -161
- package/.claude/commands/build-check.md +0 -18
- package/.claude/commands/collection-op.md +0 -53
- package/.claude/commands/docs.md +0 -49
- package/.claude/commands/feature.md +0 -38
- package/.claude/commands/fix-build.md +0 -46
- package/.claude/commands/helper.md +0 -67
- package/.claude/commands/index-op.md +0 -50
- package/.claude/commands/perf-check.md +0 -75
- package/.claude/commands/review.md +0 -12
- package/.claude/commands/tcp-command.md +0 -58
- package/.claude/commands/test.md +0 -30
- package/.claude/commands/transaction-op.md +0 -72
- package/.claude/rules/architecture.md +0 -98
- package/.claude/rules/code-standards.md +0 -282
- package/.claude/rules/commands.md +0 -40
- package/.claude/rules/documentation.md +0 -183
- package/.claude/rules/workflow.md +0 -160
- package/.codex/config.toml +0 -149
- package/.cursor/rules/axiodb-core.mdc +0 -391
- package/.gemini/settings.json +0 -53
- package/AGENTS.md +0 -371
- package/CLAUDE.md +0 -92
- package/GEMINI.md +0 -117
package/.dockerignore
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Git
|
|
2
|
+
.git/
|
|
3
|
+
.gitignore
|
|
4
|
+
.gitattributes
|
|
5
|
+
.github/
|
|
6
|
+
|
|
7
|
+
# Node modules (will be installed in container)
|
|
8
|
+
node_modules/
|
|
9
|
+
npm-debug.log
|
|
10
|
+
yarn-error.log
|
|
11
|
+
package-lock.json
|
|
12
|
+
|
|
13
|
+
# AI Assistant configurations (not needed in Docker)
|
|
14
|
+
.agents/
|
|
15
|
+
.claude/
|
|
16
|
+
.codex/
|
|
17
|
+
.cursor/
|
|
18
|
+
.devin/
|
|
19
|
+
.gemini/
|
|
20
|
+
AGENTS.md
|
|
21
|
+
CLAUDE.md
|
|
22
|
+
GEMINI.md
|
|
23
|
+
|
|
24
|
+
# IDE configurations
|
|
25
|
+
.vscode/
|
|
26
|
+
.idea/
|
|
27
|
+
.devcontainer/
|
|
28
|
+
|
|
29
|
+
# Documentation (not needed in runtime)
|
|
30
|
+
Document/
|
|
31
|
+
LEARN.md
|
|
32
|
+
CODE_OF_CONDUCT.md
|
|
33
|
+
CONTRIBUTING.md
|
|
34
|
+
SECURITY.md
|
|
35
|
+
|
|
36
|
+
# Development files
|
|
37
|
+
.gitpod.yml
|
|
38
|
+
.deepsource.toml
|
|
39
|
+
docker-compose.yml
|
|
40
|
+
eslint.config.mjs
|
|
41
|
+
tsconfig.json
|
|
42
|
+
|
|
43
|
+
# Source TypeScript files (only compiled lib/ needed)
|
|
44
|
+
source/
|
|
45
|
+
Test/
|
|
46
|
+
test/
|
|
47
|
+
*.test.js
|
|
48
|
+
*.spec.js
|
|
49
|
+
|
|
50
|
+
# Build artifacts
|
|
51
|
+
dist/
|
|
52
|
+
library/
|
|
53
|
+
Cache/
|
|
54
|
+
AxioDB/
|
|
55
|
+
|
|
56
|
+
# GUI (built separately if needed)
|
|
57
|
+
GUI/
|
|
58
|
+
|
|
59
|
+
# Scripts (development only)
|
|
60
|
+
Scripts/
|
|
61
|
+
|
|
62
|
+
# OS files
|
|
63
|
+
.DS_Store
|
|
64
|
+
Thumbs.db
|
|
65
|
+
*.swp
|
|
66
|
+
*.swo
|
|
67
|
+
*~
|
|
68
|
+
|
|
69
|
+
# Temporary files
|
|
70
|
+
*.log
|
|
71
|
+
*.tmp
|
|
72
|
+
tmp/
|
|
73
|
+
temp/
|
package/README.md
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
# AxioDB: The Pure JavaScript Alternative to SQLite
|
|
2
2
|
|
|
3
3
|
[](https://badge.fury.io/js/axiodb)
|
|
4
|
+
[](https://www.npmjs.com/package/axiodb)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
[](https://github.com/nexoral/AxioDB/actions/workflows/Push.yml)
|
|
4
8
|
[](https://github.com/nexoral/AxioDB/actions/workflows/github-code-scanning/codeql)
|
|
5
9
|
[](https://socket.dev/npm/package/axiodb)
|
|
6
|
-
|
|
10
|
+
|
|
11
|
+
[](https://nodejs.org)
|
|
12
|
+
[-blue)](https://github.com/nexoral/AxioDB/actions/workflows/Push.yml)
|
|
13
|
+
[](https://www.typescriptlang.org/)
|
|
14
|
+
[](https://www.npmjs.com/package/axiodb)
|
|
7
15
|
|
|
8
16
|
> **AxioDB** is an embedded NoSQL database for Node.js with MongoDB-style queries. Zero native dependencies, no compilation, no platform issues. Pure JavaScript from npm install to production. Think SQLite, but NoSQL with JavaScript queries—perfect for desktop apps, CLI tools, and embedded systems.
|
|
9
17
|
|
|
@@ -19,11 +19,13 @@ export default class DeleteOperation {
|
|
|
19
19
|
/**
|
|
20
20
|
* Deletes a single document that matches the base query.
|
|
21
21
|
*
|
|
22
|
-
* This method:
|
|
22
|
+
* This method with ACID compliance:
|
|
23
23
|
* 1. Loads all raw data from buffers
|
|
24
24
|
* 2. Searches for documents matching the base query
|
|
25
25
|
* 3. Selects the first matching document (applying sort if provided)
|
|
26
|
-
* 4.
|
|
26
|
+
* 4. Acquires lock on the document
|
|
27
|
+
* 5. Deletes the file associated with the selected document
|
|
28
|
+
* 6. Releases lock
|
|
27
29
|
*
|
|
28
30
|
* @returns {Promise<object>} A response object containing either:
|
|
29
31
|
* - Success: { message: "Data deleted successfully", deleteData: object }
|
|
@@ -35,15 +37,18 @@ export default class DeleteOperation {
|
|
|
35
37
|
/**
|
|
36
38
|
* Deletes multiple documents that match the base query.
|
|
37
39
|
*
|
|
38
|
-
* This method:
|
|
40
|
+
* This method with ACID compliance:
|
|
39
41
|
* 1. Searches for documents matching the base query
|
|
40
|
-
* 2.
|
|
41
|
-
* 3.
|
|
42
|
+
* 2. Acquires locks on ALL matching documents (ensures atomicity)
|
|
43
|
+
* 3. Deletes each matching file
|
|
44
|
+
* 4. Releases all locks
|
|
45
|
+
* 5. Returns success with the deleted data or an error
|
|
42
46
|
*
|
|
43
47
|
* @returns {Promise<SuccessInterface | ErrorInterface>} A promise that resolves to either:
|
|
44
48
|
* - Success with a success message and the deleted data
|
|
45
49
|
* - Error if:
|
|
46
50
|
* - No matching data is found
|
|
51
|
+
* - Lock acquisition fails
|
|
47
52
|
* - Any file deletion operation fails
|
|
48
53
|
* - The initial buffer data loading fails
|
|
49
54
|
*/
|
|
@@ -18,6 +18,7 @@ const Crypto_helper_1 = require("../../Helper/Crypto.helper");
|
|
|
18
18
|
const response_helper_1 = __importDefault(require("../../Helper/response.helper"));
|
|
19
19
|
const DocumentLoader_helper_1 = __importDefault(require("../../Helper/DocumentLoader.helper"));
|
|
20
20
|
const FileManager_1 = __importDefault(require("../../engine/Filesystem/FileManager"));
|
|
21
|
+
const crypto_1 = require("crypto");
|
|
21
22
|
// Import All Utility
|
|
22
23
|
const Searcher_utils_1 = __importDefault(require("../../utility/Searcher.utils"));
|
|
23
24
|
const SortData_utils_1 = __importDefault(require("../../utility/SortData.utils"));
|
|
@@ -25,6 +26,7 @@ const memory_operation_1 = __importDefault(require("../../Memory/memory.operatio
|
|
|
25
26
|
const Keys_1 = require("../../config/Keys/Keys");
|
|
26
27
|
const ReadIndex_service_1 = require("../Index/ReadIndex.service");
|
|
27
28
|
const DeleteIndex_service_1 = __importDefault(require("../Index/DeleteIndex.service"));
|
|
29
|
+
const LockManager_service_1 = __importDefault(require("../Transaction/LockManager.service"));
|
|
28
30
|
/**
|
|
29
31
|
* The DeleteOperation class is used to delete a document from a collection.
|
|
30
32
|
* This class provides methods to delete a single document that matches the base query.
|
|
@@ -53,11 +55,13 @@ class DeleteOperation {
|
|
|
53
55
|
/**
|
|
54
56
|
* Deletes a single document that matches the base query.
|
|
55
57
|
*
|
|
56
|
-
* This method:
|
|
58
|
+
* This method with ACID compliance:
|
|
57
59
|
* 1. Loads all raw data from buffers
|
|
58
60
|
* 2. Searches for documents matching the base query
|
|
59
61
|
* 3. Selects the first matching document (applying sort if provided)
|
|
60
|
-
* 4.
|
|
62
|
+
* 4. Acquires lock on the document
|
|
63
|
+
* 5. Deletes the file associated with the selected document
|
|
64
|
+
* 6. Releases lock
|
|
61
65
|
*
|
|
62
66
|
* @returns {Promise<object>} A response object containing either:
|
|
63
67
|
* - Success: { message: "Data deleted successfully", deleteData: object }
|
|
@@ -68,25 +72,32 @@ class DeleteOperation {
|
|
|
68
72
|
deleteOne() {
|
|
69
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
74
|
var _a;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
ReadResponse
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
ReadResponse = yield this.LoadAllBufferRawData(fileNames);
|
|
75
|
+
const lockManager = new LockManager_service_1.default(this.path);
|
|
76
|
+
const operationId = (0, crypto_1.randomUUID)();
|
|
77
|
+
const timestamp = Date.now();
|
|
78
|
+
let documentId = null;
|
|
79
|
+
try {
|
|
80
|
+
// STEP 1: Find the document first
|
|
81
|
+
let ReadResponse; // Read Response Holder
|
|
82
|
+
if (((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.documentId) !== undefined) {
|
|
83
|
+
const FilePath = [
|
|
84
|
+
`${this.baseQuery.documentId}${Keys_1.General.DBMS_File_EXT}`,
|
|
85
|
+
];
|
|
86
|
+
ReadResponse = yield this.LoadAllBufferRawData(FilePath);
|
|
84
87
|
}
|
|
85
88
|
else {
|
|
86
|
-
|
|
89
|
+
const fileNames = yield new ReadIndex_service_1.ReadIndex(this.path).getFileFromIndex(this.baseQuery);
|
|
90
|
+
if (fileNames.length > 0) {
|
|
91
|
+
// Load File Names from Index
|
|
92
|
+
ReadResponse = yield this.LoadAllBufferRawData(fileNames);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
ReadResponse = yield this.LoadAllBufferRawData();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (!("data" in ReadResponse)) {
|
|
99
|
+
return this.ResponseHelper.Error(ReadResponse);
|
|
87
100
|
}
|
|
88
|
-
}
|
|
89
|
-
if ("data" in ReadResponse) {
|
|
90
101
|
const SearchedData = yield new Searcher_utils_1.default(ReadResponse.data, true).find(this.baseQuery, "data");
|
|
91
102
|
if (SearchedData.length === 0) {
|
|
92
103
|
return this.ResponseHelper.Error("No data found with the specified query");
|
|
@@ -94,91 +105,113 @@ class DeleteOperation {
|
|
|
94
105
|
let selectedFirstData = SearchedData[0]; // Select the first data
|
|
95
106
|
let fileName = selectedFirstData === null || selectedFirstData === void 0 ? void 0 : selectedFirstData.fileName; // Get the file name
|
|
96
107
|
// Sort the data if sort is provided then select the first data for deletion
|
|
97
|
-
if (Object.keys(this.sort).length
|
|
98
|
-
selectedFirstData = SearchedData[0]; // Select the first data
|
|
99
|
-
fileName = selectedFirstData === null || selectedFirstData === void 0 ? void 0 : selectedFirstData.fileName; // Get the file name
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
108
|
+
if (Object.keys(this.sort).length !== 0) {
|
|
102
109
|
const Sorter = new SortData_utils_1.default(SearchedData, this.sort);
|
|
103
110
|
const SortedData = yield Sorter.sort("data"); // Sort the data
|
|
104
111
|
selectedFirstData = SortedData[0]; // Select the first data
|
|
105
112
|
fileName = selectedFirstData === null || selectedFirstData === void 0 ? void 0 : selectedFirstData.fileName; // Get the file name
|
|
106
113
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
new DeleteIndex_service_1.default(this.path).RemoveFromIndex(documentId, selectedFirstData === null || selectedFirstData === void 0 ? void 0 : selectedFirstData.data).catch(() => { });
|
|
113
|
-
memory_operation_1.default.invalidateByDocument(this.path, documentId).catch(() => { });
|
|
114
|
-
return this.ResponseHelper.Success({
|
|
115
|
-
message: "Data deleted successfully",
|
|
116
|
-
deleteData: selectedFirstData === null || selectedFirstData === void 0 ? void 0 : selectedFirstData.data,
|
|
117
|
-
});
|
|
114
|
+
documentId = fileName.split('.')[0];
|
|
115
|
+
// STEP 2: Acquire lock on the document (ACID: Isolation)
|
|
116
|
+
const lockResult = yield lockManager.acquireLock(documentId, operationId, timestamp);
|
|
117
|
+
if (!("data" in lockResult)) {
|
|
118
|
+
return this.ResponseHelper.Error("Lock acquisition failed");
|
|
118
119
|
}
|
|
119
|
-
|
|
120
|
+
// STEP 3: Delete the file (now safe - locked)
|
|
121
|
+
const deleteResponse = yield this.deleteFile(fileName);
|
|
122
|
+
if (!("data" in deleteResponse)) {
|
|
120
123
|
return this.ResponseHelper.Error("Failed to delete data");
|
|
121
124
|
}
|
|
125
|
+
// Fire-and-forget: Remove from indexes and invalidate cache asynchronously for faster response
|
|
126
|
+
new DeleteIndex_service_1.default(this.path).RemoveFromIndex(documentId, selectedFirstData === null || selectedFirstData === void 0 ? void 0 : selectedFirstData.data).catch(() => { });
|
|
127
|
+
memory_operation_1.default.invalidateByDocument(this.path, documentId).catch(() => { });
|
|
128
|
+
return this.ResponseHelper.Success({
|
|
129
|
+
message: "Data deleted successfully",
|
|
130
|
+
deleteData: selectedFirstData === null || selectedFirstData === void 0 ? void 0 : selectedFirstData.data,
|
|
131
|
+
});
|
|
122
132
|
}
|
|
123
|
-
|
|
124
|
-
|
|
133
|
+
finally {
|
|
134
|
+
// STEP 4: Always release lock (ACID: ensures no deadlock)
|
|
135
|
+
if (documentId) {
|
|
136
|
+
yield lockManager.releaseLock(documentId).catch(() => { });
|
|
137
|
+
}
|
|
125
138
|
}
|
|
126
139
|
});
|
|
127
140
|
}
|
|
128
141
|
/**
|
|
129
142
|
* Deletes multiple documents that match the base query.
|
|
130
143
|
*
|
|
131
|
-
* This method:
|
|
144
|
+
* This method with ACID compliance:
|
|
132
145
|
* 1. Searches for documents matching the base query
|
|
133
|
-
* 2.
|
|
134
|
-
* 3.
|
|
146
|
+
* 2. Acquires locks on ALL matching documents (ensures atomicity)
|
|
147
|
+
* 3. Deletes each matching file
|
|
148
|
+
* 4. Releases all locks
|
|
149
|
+
* 5. Returns success with the deleted data or an error
|
|
135
150
|
*
|
|
136
151
|
* @returns {Promise<SuccessInterface | ErrorInterface>} A promise that resolves to either:
|
|
137
152
|
* - Success with a success message and the deleted data
|
|
138
153
|
* - Error if:
|
|
139
154
|
* - No matching data is found
|
|
155
|
+
* - Lock acquisition fails
|
|
140
156
|
* - Any file deletion operation fails
|
|
141
157
|
* - The initial buffer data loading fails
|
|
142
158
|
*/
|
|
143
159
|
deleteMany() {
|
|
144
160
|
return __awaiter(this, void 0, void 0, function* () {
|
|
145
|
-
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
161
|
+
const lockManager = new LockManager_service_1.default(this.path);
|
|
162
|
+
const operationId = (0, crypto_1.randomUUID)();
|
|
163
|
+
const timestamp = Date.now();
|
|
164
|
+
const acquiredLocks = [];
|
|
165
|
+
try {
|
|
166
|
+
// STEP 1: Find all matching documents
|
|
167
|
+
let response;
|
|
168
|
+
const fileNames = yield new ReadIndex_service_1.ReadIndex(this.path).getFileFromIndex(this.baseQuery);
|
|
169
|
+
if (fileNames.length > 0) {
|
|
170
|
+
// Load File Names from Index
|
|
171
|
+
response = yield this.LoadAllBufferRawData(fileNames);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
response = yield this.LoadAllBufferRawData();
|
|
175
|
+
}
|
|
176
|
+
if (!("data" in response)) {
|
|
177
|
+
return this.ResponseHelper.Error(response);
|
|
178
|
+
}
|
|
155
179
|
const SearchedData = yield new Searcher_utils_1.default(response.data, true).find(this.baseQuery, "data");
|
|
156
180
|
if (SearchedData.length === 0) {
|
|
157
181
|
return this.ResponseHelper.Error("No data found with the specified query");
|
|
158
182
|
}
|
|
159
|
-
//
|
|
183
|
+
// STEP 2: Extract all document IDs and acquire locks on ALL documents
|
|
184
|
+
const documentIds = SearchedData.map((data) => data.fileName.split('.')[0]);
|
|
185
|
+
for (const docId of documentIds) {
|
|
186
|
+
const lockResult = yield lockManager.acquireLock(docId, operationId, timestamp);
|
|
187
|
+
if (!("data" in lockResult)) {
|
|
188
|
+
// Lock acquisition failed - rollback
|
|
189
|
+
return this.ResponseHelper.Error(`Lock acquisition failed for document ${docId}`);
|
|
190
|
+
}
|
|
191
|
+
acquiredLocks.push(docId);
|
|
192
|
+
}
|
|
193
|
+
// STEP 3: All locks acquired - now perform deletions safely
|
|
160
194
|
const deleteIndexService = new DeleteIndex_service_1.default(this.path);
|
|
161
195
|
for (let i = 0; i < SearchedData.length; i++) {
|
|
162
196
|
const deleteResponse = yield this.deleteFile(SearchedData[i].fileName);
|
|
163
|
-
if ("data" in deleteResponse) {
|
|
164
|
-
// Fire-and-forget: Remove from indexes asynchronously
|
|
165
|
-
deleteIndexService.RemoveFromIndex(SearchedData[i].fileName.split('.')[0], SearchedData[i].data).catch(() => { });
|
|
166
|
-
continue;
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
197
|
+
if (!("data" in deleteResponse)) {
|
|
169
198
|
return this.ResponseHelper.Error("Failed to delete data");
|
|
170
199
|
}
|
|
200
|
+
// Fire-and-forget: Remove from indexes asynchronously
|
|
201
|
+
deleteIndexService.RemoveFromIndex(SearchedData[i].fileName.split('.')[0], SearchedData[i].data).catch(() => { });
|
|
171
202
|
}
|
|
172
203
|
// Fire-and-forget: Invalidate cache asynchronously
|
|
173
|
-
const documentIds = SearchedData.map((data) => data.fileName.split('.')[0]);
|
|
174
204
|
memory_operation_1.default.invalidateByDocuments(this.path, documentIds).catch(() => { });
|
|
175
205
|
return this.ResponseHelper.Success({
|
|
176
206
|
message: "Data deleted successfully",
|
|
177
207
|
deleteData: SearchedData.map((data) => data.data),
|
|
178
208
|
});
|
|
179
209
|
}
|
|
180
|
-
|
|
181
|
-
|
|
210
|
+
finally {
|
|
211
|
+
// STEP 4: Always release ALL acquired locks (ACID: ensures no deadlock)
|
|
212
|
+
if (acquiredLocks.length > 0) {
|
|
213
|
+
yield lockManager.releaseAllLocks(acquiredLocks).catch(() => { });
|
|
214
|
+
}
|
|
182
215
|
}
|
|
183
216
|
});
|
|
184
217
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Delete.operation.js","sourceRoot":"","sources":["../../../source/Services/CRUD Operation/Delete.operation.ts"],"names":[],"mappings":";AAAA,uDAAuD;;;;;;;;;;;;;;AAMvD,qFAAsD;AACtD,8DAA0D;AAC1D,mFAA0D;AAC1D,+FAAgE;AAChE,sFAA8D;
|
|
1
|
+
{"version":3,"file":"Delete.operation.js","sourceRoot":"","sources":["../../../source/Services/CRUD Operation/Delete.operation.ts"],"names":[],"mappings":";AAAA,uDAAuD;;;;;;;;;;;;;;AAMvD,qFAAsD;AACtD,8DAA0D;AAC1D,mFAA0D;AAC1D,+FAAgE;AAChE,sFAA8D;AAC9D,mCAAoC;AAEpC,qBAAqB;AACrB,kFAAoD;AACpD,kFAAmD;AACnD,qFAA0D;AAC1D,iDAAiD;AACjD,kEAAuD;AACvD,uFAAuD;AACvD,6FAA6D;AAC7D;;;GAGG;AACH,MAAqB,eAAe;IAclC,YACE,cAAsB,EACtB,IAAY,EACZ,SAAuB,EACvB,cAAuB,KAAK,EAC5B,aAAsB;QARhB,wBAAmB,GAAU,EAAE,CAAC;QAUtC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SA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OAWG;IACW,UAAU,CAAC,QAAgB;;YACvC,yEAAyE;YACzE,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACxE,CAAC;KAAA;IAED;;;;OAIG;IACI,IAAI,CAAC,IAAkB;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AArSD,kCAqSC"}
|
|
@@ -17,31 +17,35 @@ export default class UpdateOperation {
|
|
|
17
17
|
/**
|
|
18
18
|
* Updates a single document that matches the base query.
|
|
19
19
|
*
|
|
20
|
-
* This method performs the following operations:
|
|
21
|
-
* 1.
|
|
22
|
-
* 2.
|
|
23
|
-
* 3.
|
|
24
|
-
* 4.
|
|
20
|
+
* This method performs the following operations with ACID compliance:
|
|
21
|
+
* 1. Acquires lock on document to ensure atomicity and isolation
|
|
22
|
+
* 2. Searches for documents matching the base query
|
|
23
|
+
* 3. If documents are found, selects the first document (or first after sorting if sort criteria are provided)
|
|
24
|
+
* 4. Deletes the existing document file
|
|
25
|
+
* 5. Inserts a new file with updated data using the same document ID
|
|
26
|
+
* 6. Releases lock
|
|
25
27
|
*
|
|
26
28
|
* @param newData - The new data to replace the existing document
|
|
27
29
|
* @returns A Promise resolving to:
|
|
28
30
|
* - Success with updated data and previous data if successful
|
|
29
|
-
* - Error if any step fails
|
|
31
|
+
* - Error if any step fails (lock acquisition, read, update)
|
|
30
32
|
* @throws May throw errors during file operations or data processing
|
|
31
33
|
*/
|
|
32
34
|
UpdateOne(newData: object | any): Promise<SuccessInterface | ErrorInterface>;
|
|
33
35
|
/**
|
|
34
36
|
* Updates multiple documents that match the base query.
|
|
35
37
|
*
|
|
36
|
-
* This method performs the following operations:
|
|
38
|
+
* This method performs the following operations with ACID compliance:
|
|
37
39
|
* 1. Searches for documents matching the base query
|
|
38
|
-
* 2.
|
|
39
|
-
* 3.
|
|
40
|
+
* 2. Acquires locks on ALL matching documents (ensures atomicity across all updates)
|
|
41
|
+
* 3. Deletes the existing documents
|
|
42
|
+
* 4. Inserts new files with updated data for each document
|
|
43
|
+
* 5. Releases all locks
|
|
40
44
|
*
|
|
41
45
|
* @param newData - The new data to replace the existing documents
|
|
42
46
|
* @returns A Promise resolving to:
|
|
43
47
|
* - Success with updated data and previous data if successful
|
|
44
|
-
* - Error if any step fails
|
|
48
|
+
* - Error if any step fails (rollback by releasing all acquired locks)
|
|
45
49
|
* @throws May throw errors during file operations or data processing
|
|
46
50
|
*/
|
|
47
51
|
UpdateMany(newData: object | any): Promise<SuccessInterface | ErrorInterface>;
|