axiodb 2.30.93 → 2.31.94
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/Services/Aggregation/Aggregation.Operation.js +10 -47
- package/lib/Services/Aggregation/Aggregation.Operation.js.map +1 -1
- package/lib/Services/CRUD Operation/Create.operation.js +7 -53
- package/lib/Services/CRUD Operation/Create.operation.js.map +1 -1
- package/lib/Services/CRUD Operation/Delete.operation.js +12 -51
- package/lib/Services/CRUD Operation/Delete.operation.js.map +1 -1
- package/lib/Services/CRUD Operation/Reader.operation.js +12 -51
- package/lib/Services/CRUD Operation/Reader.operation.js.map +1 -1
- package/lib/Services/CRUD Operation/Update.operation.js +12 -51
- package/lib/Services/CRUD Operation/Update.operation.js.map +1 -1
- package/lib/Services/Indexation.operation.d.ts +5 -0
- package/lib/Services/Indexation.operation.js +7 -0
- package/lib/Services/Indexation.operation.js.map +1 -1
- package/lib/server/config/keys.js +30 -28
- package/lib/server/config/keys.js.map +1 -1
- package/lib/server/controller/Collections/Collection.controller.d.ts +1 -1
- package/lib/server/controller/Collections/Collection.controller.js +1 -15
- package/lib/server/controller/Collections/Collection.controller.js.map +1 -1
- package/lib/server/controller/Database/Databse.controller.d.ts +32 -2
- package/lib/server/controller/Database/Databse.controller.js +157 -14
- package/lib/server/controller/Database/Databse.controller.js.map +1 -1
- package/lib/server/controller/Operation/CRUD.controller.js +0 -9
- package/lib/server/controller/Operation/CRUD.controller.js.map +1 -1
- package/lib/server/controller/Stats.controller.d.ts +1 -1
- package/lib/server/controller/Stats.controller.js +1 -14
- package/lib/server/controller/Stats.controller.js.map +1 -1
- package/lib/server/public/AxioControl/.vite/manifest.json +2 -2
- package/lib/server/public/AxioControl/.vite/ssr-manifest.json +258 -0
- package/lib/server/public/AxioControl/assets/index-CdykjE_a.css +1 -0
- package/lib/server/public/AxioControl/assets/index-DImn3ep-.js +75 -0
- package/lib/server/public/AxioControl/index.html +2 -2
- package/lib/server/public/AxioControl/sw.js +1 -1
- package/lib/server/router/Router.js +1 -21
- package/lib/server/router/Router.js.map +1 -1
- package/lib/server/router/Routers/Collection.routes.js +1 -3
- package/lib/server/router/Routers/Collection.routes.js.map +1 -1
- package/lib/server/router/Routers/DB.routes.js +7 -3
- package/lib/server/router/Routers/DB.routes.js.map +1 -1
- package/lib/utility/ZipUnzip.utils.d.ts +31 -0
- package/lib/utility/ZipUnzip.utils.js +117 -0
- package/lib/utility/ZipUnzip.utils.js.map +1 -0
- package/package.json +6 -3
- package/lib/server/config/GlobalStorage.config.d.ts +0 -66
- package/lib/server/config/GlobalStorage.config.js +0 -95
- package/lib/server/config/GlobalStorage.config.js.map +0 -1
- package/lib/server/public/AxioControl/assets/index-CEUHQ44S.css +0 -1
- package/lib/server/public/AxioControl/assets/index-Cub2B5F8.js +0 -67
|
@@ -50,29 +50,18 @@ exports.AvailableRoutes = [
|
|
|
50
50
|
},
|
|
51
51
|
],
|
|
52
52
|
},
|
|
53
|
-
{
|
|
54
|
-
groupName: "Key Management",
|
|
55
|
-
description: "Key Management Endpoints",
|
|
56
|
-
Paths: [
|
|
57
|
-
{
|
|
58
|
-
method: "GET",
|
|
59
|
-
path: "/api/get-token",
|
|
60
|
-
description: "Get a new token for transacting with AxioDB Server",
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
},
|
|
64
53
|
{
|
|
65
54
|
groupName: "Database",
|
|
66
55
|
description: "Database Management Endpoints",
|
|
67
56
|
Paths: [
|
|
68
57
|
{
|
|
69
58
|
method: "GET",
|
|
70
|
-
path: "/api/db/databases
|
|
59
|
+
path: "/api/db/databases/",
|
|
71
60
|
description: "Get a list of all databases",
|
|
72
61
|
},
|
|
73
62
|
{
|
|
74
63
|
method: "POST",
|
|
75
|
-
path: "/api/db/create-database
|
|
64
|
+
path: "/api/db/create-database/",
|
|
76
65
|
description: "Create a new database",
|
|
77
66
|
payload: {
|
|
78
67
|
name: "string",
|
|
@@ -80,12 +69,25 @@ exports.AvailableRoutes = [
|
|
|
80
69
|
},
|
|
81
70
|
{
|
|
82
71
|
method: "DELETE",
|
|
83
|
-
path: "/api/db/delete-database
|
|
72
|
+
path: "/api/db/delete-database/",
|
|
84
73
|
description: "Delete a database",
|
|
85
74
|
payload: {
|
|
86
75
|
name: "string",
|
|
87
76
|
},
|
|
88
77
|
},
|
|
78
|
+
{
|
|
79
|
+
method: "GET",
|
|
80
|
+
path: "/api/db/export-database/?dbName",
|
|
81
|
+
description: "Export a database as a compressed file",
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
method: "POST",
|
|
85
|
+
path: "/api/db/import-database/",
|
|
86
|
+
description: "Import a database from a compressed file",
|
|
87
|
+
payload: {
|
|
88
|
+
file: "file",
|
|
89
|
+
},
|
|
90
|
+
},
|
|
89
91
|
],
|
|
90
92
|
},
|
|
91
93
|
{
|
|
@@ -94,12 +96,12 @@ exports.AvailableRoutes = [
|
|
|
94
96
|
Paths: [
|
|
95
97
|
{
|
|
96
98
|
method: "GET",
|
|
97
|
-
path: "/api/collection/all/?databaseName
|
|
99
|
+
path: "/api/collection/all/?databaseName",
|
|
98
100
|
description: "Get a list of all collections",
|
|
99
101
|
},
|
|
100
102
|
{
|
|
101
103
|
method: "POST",
|
|
102
|
-
path: "/api/collection/create-collection
|
|
104
|
+
path: "/api/collection/create-collection/",
|
|
103
105
|
description: "Create a new collection",
|
|
104
106
|
payload: {
|
|
105
107
|
dbName: "string",
|
|
@@ -110,7 +112,7 @@ exports.AvailableRoutes = [
|
|
|
110
112
|
},
|
|
111
113
|
{
|
|
112
114
|
method: "DELETE",
|
|
113
|
-
path: "/api/collection/delete-collection/?dbName&collectionName
|
|
115
|
+
path: "/api/collection/delete-collection/?dbName&collectionName",
|
|
114
116
|
description: "Delete a collection",
|
|
115
117
|
},
|
|
116
118
|
],
|
|
@@ -122,12 +124,12 @@ exports.AvailableRoutes = [
|
|
|
122
124
|
{
|
|
123
125
|
method: "GET",
|
|
124
126
|
description: "Get all documents from a collection",
|
|
125
|
-
path: "/api/operation/all/?dbName&collectionName&page
|
|
127
|
+
path: "/api/operation/all/?dbName&collectionName&page",
|
|
126
128
|
},
|
|
127
129
|
{
|
|
128
130
|
method: "POST",
|
|
129
131
|
description: "Get all documents from a collection by query",
|
|
130
|
-
path: "/api/operation/all/by-query/?dbName&collectionName&page
|
|
132
|
+
path: "/api/operation/all/by-query/?dbName&collectionName&page",
|
|
131
133
|
payload: {
|
|
132
134
|
query: "object",
|
|
133
135
|
},
|
|
@@ -135,12 +137,12 @@ exports.AvailableRoutes = [
|
|
|
135
137
|
{
|
|
136
138
|
method: "GET",
|
|
137
139
|
description: "Get specific documents from a collection by ID",
|
|
138
|
-
path: "/api/operation/all/by-id/?dbName&collectionName&documentId
|
|
140
|
+
path: "/api/operation/all/by-id/?dbName&collectionName&documentId",
|
|
139
141
|
},
|
|
140
142
|
{
|
|
141
143
|
method: "POST",
|
|
142
144
|
description: "Create a new document in a collection",
|
|
143
|
-
path: "/api/operation/create/?dbName&collectionName
|
|
145
|
+
path: "/api/operation/create/?dbName&collectionName",
|
|
144
146
|
payload: {
|
|
145
147
|
document: "full object with no key in body",
|
|
146
148
|
},
|
|
@@ -148,7 +150,7 @@ exports.AvailableRoutes = [
|
|
|
148
150
|
{
|
|
149
151
|
method: "POST",
|
|
150
152
|
description: "Create a new document in a collection",
|
|
151
|
-
path: "/api/operation/create-many/?dbName&collectionName
|
|
153
|
+
path: "/api/operation/create-many/?dbName&collectionName",
|
|
152
154
|
payload: {
|
|
153
155
|
documents: "full array of object with no key in body",
|
|
154
156
|
},
|
|
@@ -156,7 +158,7 @@ exports.AvailableRoutes = [
|
|
|
156
158
|
{
|
|
157
159
|
method: "PUT",
|
|
158
160
|
description: "Update an existing document in a collection by ID",
|
|
159
|
-
path: "/api/operation/update/by-id/?dbName&collectionName&documentId
|
|
161
|
+
path: "/api/operation/update/by-id/?dbName&collectionName&documentId",
|
|
160
162
|
payload: {
|
|
161
163
|
document: "full object with no key in body",
|
|
162
164
|
},
|
|
@@ -164,7 +166,7 @@ exports.AvailableRoutes = [
|
|
|
164
166
|
{
|
|
165
167
|
method: "PUT",
|
|
166
168
|
description: "Update an existing document in a collection by query",
|
|
167
|
-
path: "/api/operation/update/by-query/?dbName&isMany&collectionName
|
|
169
|
+
path: "/api/operation/update/by-query/?dbName&isMany&collectionName",
|
|
168
170
|
payload: {
|
|
169
171
|
query: "object",
|
|
170
172
|
update: "object",
|
|
@@ -173,12 +175,12 @@ exports.AvailableRoutes = [
|
|
|
173
175
|
{
|
|
174
176
|
method: "DELETE",
|
|
175
177
|
description: "Delete an existing document in a collection by ID",
|
|
176
|
-
path: "/api/operation/delete/by-id/?dbName&collectionName&documentId
|
|
178
|
+
path: "/api/operation/delete/by-id/?dbName&collectionName&documentId",
|
|
177
179
|
},
|
|
178
180
|
{
|
|
179
181
|
method: "DELETE",
|
|
180
182
|
description: "Delete an existing document in a collection by query",
|
|
181
|
-
path: "/api/operation/delete/by-query/?dbName&collectionName&isMany&documentId
|
|
183
|
+
path: "/api/operation/delete/by-query/?dbName&collectionName&isMany&documentId",
|
|
182
184
|
payload: {
|
|
183
185
|
query: "object",
|
|
184
186
|
},
|
|
@@ -186,7 +188,7 @@ exports.AvailableRoutes = [
|
|
|
186
188
|
{
|
|
187
189
|
method: "POST",
|
|
188
190
|
description: "Perform aggregation on documents in a collection using an aggregation pipeline",
|
|
189
|
-
path: "/api/operation/aggregate/?dbName&collectionName
|
|
191
|
+
path: "/api/operation/aggregate/?dbName&collectionName",
|
|
190
192
|
payload: {
|
|
191
193
|
aggregation: "array",
|
|
192
194
|
},
|
|
@@ -200,6 +202,6 @@ exports.AuthorInfo = {
|
|
|
200
202
|
Country: "India",
|
|
201
203
|
Email: "ankansahaofficial@gmail.com",
|
|
202
204
|
LinkedIn: "https://www.linkedin.com/in/theankansaha/",
|
|
203
|
-
github: "https://github.com/AnkanSaha"
|
|
205
|
+
github: "https://github.com/AnkanSaha",
|
|
204
206
|
};
|
|
205
207
|
//# sourceMappingURL=keys.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../source/server/config/keys.ts"],"names":[],"mappings":";;;;;;AAAA,uDAAuD;AACvD,gDAAwB;AAExB,IAAY,UASX;AATD,WAAY,UAAU;IACpB,+CAAY,CAAA;IACZ,mCAAqB,CAAA;IACrB,wCAA0B,CAAA;IAC1B,kDAAoC,CAAA;IACpC,oDAAsC,CAAA;IACtC,uEAAyD,CAAA;IACzD,iDAAwB,IAAI,CAAC,GAAG,EAAE,2BAAA,CAAA;IAClC,uEAAsB,CAAA;AACxB,CAAC,EATW,UAAU,0BAAV,UAAU,QASrB;AAED,kBAAkB;AACL,QAAA,WAAW,GAAG;IACzB,MAAM,EAAE,GAAG;IACX,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC;IAC1D,eAAe,EAAE,CAAC,cAAc,EAAE,eAAe,CAAC;IAClD,eAAe,EAAE,CAAC,gBAAgB,EAAE,kBAAkB,CAAC;IACvD,OAAO,EAAE,KAAK,EAAE,sBAAsB;IACtC,iBAAiB,EAAE,IAAI;CACxB,CAAC;AAEW,QAAA,UAAU,GAAW,cAAI,CAAC,OAAO,CAC5C,SAAS,EACT,uBAAuB,CACxB,CAAC;AAcF,SAAS;AACI,QAAA,eAAe,GAA0B;IACpD;QACE,SAAS,EAAE,aAAa;QACxB,WAAW,EAAE,uBAAuB;QACpC,KAAK,EAAE;YACL;gBACE,MAAM,EAAE,KAAK;gBACb,IAAI,EAAE,WAAW;gBACjB,WAAW,EAAE,2CAA2C;aACzD;YACD;gBACE,MAAM,EAAE,KAAK;gBACb,IAAI,EAAE,aAAa;gBACnB,WAAW,EAAE,+CAA+C;aAC7D;YACD;gBACE,MAAM,EAAE,KAAK;gBACb,IAAI,EAAE,aAAa;gBACnB,WAAW,EAAE,+BAA+B;aAC7C;SACF;KACF;IACD;QACE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../source/server/config/keys.ts"],"names":[],"mappings":";;;;;;AAAA,uDAAuD;AACvD,gDAAwB;AAExB,IAAY,UASX;AATD,WAAY,UAAU;IACpB,+CAAY,CAAA;IACZ,mCAAqB,CAAA;IACrB,wCAA0B,CAAA;IAC1B,kDAAoC,CAAA;IACpC,oDAAsC,CAAA;IACtC,uEAAyD,CAAA;IACzD,iDAAwB,IAAI,CAAC,GAAG,EAAE,2BAAA,CAAA;IAClC,uEAAsB,CAAA;AACxB,CAAC,EATW,UAAU,0BAAV,UAAU,QASrB;AAED,kBAAkB;AACL,QAAA,WAAW,GAAG;IACzB,MAAM,EAAE,GAAG;IACX,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC;IAC1D,eAAe,EAAE,CAAC,cAAc,EAAE,eAAe,CAAC;IAClD,eAAe,EAAE,CAAC,gBAAgB,EAAE,kBAAkB,CAAC;IACvD,OAAO,EAAE,KAAK,EAAE,sBAAsB;IACtC,iBAAiB,EAAE,IAAI;CACxB,CAAC;AAEW,QAAA,UAAU,GAAW,cAAI,CAAC,OAAO,CAC5C,SAAS,EACT,uBAAuB,CACxB,CAAC;AAcF,SAAS;AACI,QAAA,eAAe,GAA0B;IACpD;QACE,SAAS,EAAE,aAAa;QACxB,WAAW,EAAE,uBAAuB;QACpC,KAAK,EAAE;YACL;gBACE,MAAM,EAAE,KAAK;gBACb,IAAI,EAAE,WAAW;gBACjB,WAAW,EAAE,2CAA2C;aACzD;YACD;gBACE,MAAM,EAAE,KAAK;gBACb,IAAI,EAAE,aAAa;gBACnB,WAAW,EAAE,+CAA+C;aAC7D;YACD;gBACE,MAAM,EAAE,KAAK;gBACb,IAAI,EAAE,aAAa;gBACnB,WAAW,EAAE,+BAA+B;aAC7C;SACF;KACF;IACD;QACE,SAAS,EAAE,UAAU;QACrB,WAA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AE,OAAO;iBACrB;aACF;SACF;KACF;CACF,CAAC;AAWW,QAAA,UAAU,GAAmB;IACxC,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,mBAAmB;IAChC,OAAO,EAAE,OAAO;IAChB,KAAK,EAAE,6BAA6B;IACpC,QAAQ,EAAE,2CAA2C;IACrD,MAAM,EAAE,8BAA8B;CACvC,CAAC"}
|
|
@@ -36,7 +36,7 @@ export default class CollectionController {
|
|
|
36
36
|
* @throws Will return a BAD_REQUEST response if databaseName is not provided
|
|
37
37
|
* @throws Will return an INTERNAL_SERVER_ERROR response if collection retrieval fails
|
|
38
38
|
*/
|
|
39
|
-
getCollections(request: FastifyRequest
|
|
39
|
+
getCollections(request: FastifyRequest): Promise<ResponseBuilder>;
|
|
40
40
|
/**
|
|
41
41
|
* Deletes a collection from a specified database.
|
|
42
42
|
*
|
|
@@ -16,7 +16,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
16
16
|
const outers_1 = require("outers");
|
|
17
17
|
const responseBuilder_helper_1 = __importDefault(require("../../helper/responseBuilder.helper"));
|
|
18
18
|
const filesCounterInFolder_helper_1 = __importDefault(require("../../helper/filesCounterInFolder.helper"));
|
|
19
|
-
const GlobalStorage_config_1 = __importDefault(require("../../config/GlobalStorage.config"));
|
|
20
19
|
/**
|
|
21
20
|
* Controller class for managing collections in AxioDB.
|
|
22
21
|
*
|
|
@@ -57,7 +56,6 @@ class CollectionController {
|
|
|
57
56
|
// Creating the collection
|
|
58
57
|
try {
|
|
59
58
|
yield databaseInstance.createCollection(collectionName, crypto, key);
|
|
60
|
-
GlobalStorage_config_1.default.clear();
|
|
61
59
|
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.CREATED, "Collection created successfully", {
|
|
62
60
|
dbName,
|
|
63
61
|
collectionName,
|
|
@@ -83,16 +81,11 @@ class CollectionController {
|
|
|
83
81
|
* @throws Will return a BAD_REQUEST response if databaseName is not provided
|
|
84
82
|
* @throws Will return an INTERNAL_SERVER_ERROR response if collection retrieval fails
|
|
85
83
|
*/
|
|
86
|
-
getCollections(request
|
|
84
|
+
getCollections(request) {
|
|
87
85
|
return __awaiter(this, void 0, void 0, function* () {
|
|
88
86
|
var _a;
|
|
89
87
|
// extract databaseName from url query
|
|
90
88
|
const { databaseName } = request.query;
|
|
91
|
-
// check cache
|
|
92
|
-
if (transactionToken &&
|
|
93
|
-
GlobalStorage_config_1.default.get(`${databaseName}${transactionToken}`) != undefined) {
|
|
94
|
-
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.OK, "Dashboard stats fetched successfully", GlobalStorage_config_1.default.get(`${databaseName}${transactionToken}`));
|
|
95
|
-
}
|
|
96
89
|
if (!databaseName) {
|
|
97
90
|
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.BAD_REQUEST, "Database name is required");
|
|
98
91
|
}
|
|
@@ -110,12 +103,6 @@ class CollectionController {
|
|
|
110
103
|
mainData.CollectionSizeMap.push({ folderPath, fileCount });
|
|
111
104
|
})),
|
|
112
105
|
]);
|
|
113
|
-
// Cache the response
|
|
114
|
-
if (transactionToken &&
|
|
115
|
-
GlobalStorage_config_1.default.get(`${databaseName}${transactionToken}`) ==
|
|
116
|
-
undefined) {
|
|
117
|
-
GlobalStorage_config_1.default.set(`${databaseName}${transactionToken}`, mainData);
|
|
118
|
-
}
|
|
119
106
|
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.OK, "Collections retrieved successfully", mainData);
|
|
120
107
|
}
|
|
121
108
|
catch (error) {
|
|
@@ -157,7 +144,6 @@ class CollectionController {
|
|
|
157
144
|
}
|
|
158
145
|
try {
|
|
159
146
|
yield databaseInstance.deleteCollection(collectionName);
|
|
160
|
-
GlobalStorage_config_1.default.clear();
|
|
161
147
|
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.OK, "Collection deleted successfully");
|
|
162
148
|
}
|
|
163
149
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Collection.controller.js","sourceRoot":"","sources":["../../../../source/server/controller/Collections/Collection.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,uDAAuD;AACvD,mCAAqC;AAErC,iGAE6C;AAE7C,2GAA2E;AAC3E
|
|
1
|
+
{"version":3,"file":"Collection.controller.js","sourceRoot":"","sources":["../../../../source/server/controller/Collections/Collection.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,uDAAuD;AACvD,mCAAqC;AAErC,iGAE6C;AAE7C,2GAA2E;AAC3E;;;;;;GAMG;AACH,MAAqB,oBAAoB;IAGvC,YAAY,cAAsB;QAChC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;IAED;;;;;;;;;OASG;IACU,gBAAgB,CAC3B,OAAuB;;YAEvB,8CAA8C;YAC9C,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAKvD,CAAC;YAEF,kCAAkC;YAClC,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;gBAC1C,OAAO,IAAA,gCAAa,EAAC,oBAAW,CAAC,WAAW,EAAE,uBAAuB,CAAC,CAAC;YACzE,CAAC;YACD,IAAI,CAAC,cAAc,IAAI,OAAO,cAAc,KAAK,QAAQ,EAAE,CAAC;gBAC1D,OAAO,IAAA,gCAAa,EAAC,oBAAW,CAAC,WAAW,EAAE,yBAAyB,CAAC,CAAC;YAC3E,CAAC;YAED,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YAEpE,MAAM,kBAAkB,GACtB,MAAM,gBAAgB,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;YAC5D,IAAI,kBAAkB,EAAE,CAAC;gBACvB,OAAO,IAAA,gCAAa,EAAC,oBAAW,CAAC,QAAQ,EAAE,2BAA2B,CAAC,CAAC;YAC1E,CAAC;YACD,0BAA0B;YAC1B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E,CAAC;gBACxB,OAAO,IAAA,gCAAa,EAAC,oBAAW,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAC;YACtE,CAAC;YAED,IAAI,CAAC;gBACH,MAAM,gBAAgB,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC;gBACxD,OAAO,IAAA,gCAAa,EAAC,oBAAW,CAAC,EAAE,EAAE,iCAAiC,CAAC,CAAC;YAC1E,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC;gBACnD,OAAO,IAAA,gCAAa,EAClB,oBAAW,CAAC,qBAAqB,EACjC,6BAA6B,CAC9B,CAAC;YACJ,CAAC;QACH,CAAC;KAAA;CACF;AAhLD,uCAgLC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AxioDB } from "../../../Services/Indexation.operation";
|
|
2
2
|
import { ResponseBuilder } from "../../helper/responseBuilder.helper";
|
|
3
|
-
import { FastifyRequest } from "fastify";
|
|
3
|
+
import { FastifyReply, FastifyRequest } from "fastify";
|
|
4
4
|
/**
|
|
5
5
|
* Controller class for managing databases in AxioDB.
|
|
6
6
|
*
|
|
@@ -21,7 +21,7 @@ export default class DatabaseController {
|
|
|
21
21
|
* const response = await databaseController.getDatabases();
|
|
22
22
|
* // Returns a ResponseBuilder with status 200 and database list
|
|
23
23
|
*/
|
|
24
|
-
getDatabases(
|
|
24
|
+
getDatabases(): Promise<ResponseBuilder>;
|
|
25
25
|
/**
|
|
26
26
|
* Creates a new database with the specified name.
|
|
27
27
|
*
|
|
@@ -49,4 +49,34 @@ export default class DatabaseController {
|
|
|
49
49
|
* }
|
|
50
50
|
*/
|
|
51
51
|
deleteDatabase(request: FastifyRequest): Promise<ResponseBuilder>;
|
|
52
|
+
/**
|
|
53
|
+
* Exports a database as a compressed tar.gz file and sends it as a downloadable attachment.
|
|
54
|
+
*
|
|
55
|
+
* @param request - The Fastify request object containing the query parameter 'dbName'
|
|
56
|
+
* @param reply - The Fastify reply object used to send the response
|
|
57
|
+
* @returns A stream of the compressed database file or an error response
|
|
58
|
+
*
|
|
59
|
+
* @throws Will return an error response if the export process fails
|
|
60
|
+
*
|
|
61
|
+
* @remarks
|
|
62
|
+
* The method creates a temporary tar.gz file of the specified database directory,
|
|
63
|
+
* streams it to the client as a downloadable file, and then deletes the temporary
|
|
64
|
+
* file once the stream is closed.
|
|
65
|
+
*/
|
|
66
|
+
exportDatabase(request: FastifyRequest, reply: FastifyReply): Promise<never>;
|
|
67
|
+
/**
|
|
68
|
+
* Imports a database from an uploaded zip file.
|
|
69
|
+
*
|
|
70
|
+
* This method handles the upload of a database file, saves it temporarily,
|
|
71
|
+
* unzips it to the AxioDB instance path, and cleans up temporary files.
|
|
72
|
+
*
|
|
73
|
+
* @param request - The Fastify request object containing the uploaded file
|
|
74
|
+
* @param reply - The Fastify reply object for sending responses
|
|
75
|
+
* @returns A response object indicating success or failure of the import operation
|
|
76
|
+
* @throws Will handle errors related to file operations and return appropriate HTTP responses
|
|
77
|
+
*/
|
|
78
|
+
importDatabase(request: FastifyRequest, reply: FastifyReply): Promise<{
|
|
79
|
+
message: string;
|
|
80
|
+
file: string;
|
|
81
|
+
}>;
|
|
52
82
|
}
|
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -15,7 +48,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
48
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
16
49
|
const outers_1 = require("outers");
|
|
17
50
|
const responseBuilder_helper_1 = __importDefault(require("../../helper/responseBuilder.helper"));
|
|
18
|
-
const
|
|
51
|
+
const ZipUnzip_utils_1 = require("../../../utility/ZipUnzip.utils");
|
|
52
|
+
const fs_1 = __importDefault(require("fs"));
|
|
53
|
+
const path_1 = __importDefault(require("path"));
|
|
19
54
|
/**
|
|
20
55
|
* Controller class for managing databases in AxioDB.
|
|
21
56
|
*
|
|
@@ -37,19 +72,9 @@ class DatabaseController {
|
|
|
37
72
|
* const response = await databaseController.getDatabases();
|
|
38
73
|
* // Returns a ResponseBuilder with status 200 and database list
|
|
39
74
|
*/
|
|
40
|
-
getDatabases(
|
|
75
|
+
getDatabases() {
|
|
41
76
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
-
// check cache
|
|
43
|
-
if (transactionToken &&
|
|
44
|
-
GlobalStorage_config_1.default.get(`database_${transactionToken}`) != undefined) {
|
|
45
|
-
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.OK, "List of Databases", GlobalStorage_config_1.default.get(`database_${transactionToken}`));
|
|
46
|
-
}
|
|
47
77
|
const databases = yield this.AxioDBInstance.getInstanceInfo();
|
|
48
|
-
// Cache the response
|
|
49
|
-
if (transactionToken &&
|
|
50
|
-
GlobalStorage_config_1.default.get(`database_${transactionToken}`) == undefined) {
|
|
51
|
-
GlobalStorage_config_1.default.set(`database_${transactionToken}`, databases === null || databases === void 0 ? void 0 : databases.data);
|
|
52
|
-
}
|
|
53
78
|
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.OK, "List of Databases", databases === null || databases === void 0 ? void 0 : databases.data);
|
|
54
79
|
});
|
|
55
80
|
}
|
|
@@ -80,7 +105,6 @@ class DatabaseController {
|
|
|
80
105
|
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.BAD_REQUEST, "Invalid database name");
|
|
81
106
|
}
|
|
82
107
|
yield this.AxioDBInstance.createDB(name);
|
|
83
|
-
GlobalStorage_config_1.default.clear();
|
|
84
108
|
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.CREATED, "Database Created", {
|
|
85
109
|
Database_Name: name,
|
|
86
110
|
});
|
|
@@ -117,7 +141,6 @@ class DatabaseController {
|
|
|
117
141
|
}
|
|
118
142
|
// delete the database
|
|
119
143
|
yield this.AxioDBInstance.deleteDatabase(dbName);
|
|
120
|
-
GlobalStorage_config_1.default.clear();
|
|
121
144
|
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.OK, "Database Deleted", {
|
|
122
145
|
Database_Name: dbName,
|
|
123
146
|
});
|
|
@@ -128,6 +151,126 @@ class DatabaseController {
|
|
|
128
151
|
}
|
|
129
152
|
});
|
|
130
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Exports a database as a compressed tar.gz file and sends it as a downloadable attachment.
|
|
156
|
+
*
|
|
157
|
+
* @param request - The Fastify request object containing the query parameter 'dbName'
|
|
158
|
+
* @param reply - The Fastify reply object used to send the response
|
|
159
|
+
* @returns A stream of the compressed database file or an error response
|
|
160
|
+
*
|
|
161
|
+
* @throws Will return an error response if the export process fails
|
|
162
|
+
*
|
|
163
|
+
* @remarks
|
|
164
|
+
* The method creates a temporary tar.gz file of the specified database directory,
|
|
165
|
+
* streams it to the client as a downloadable file, and then deletes the temporary
|
|
166
|
+
* file once the stream is closed.
|
|
167
|
+
*/
|
|
168
|
+
exportDatabase(request, reply) {
|
|
169
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
170
|
+
const { dbName } = request.query;
|
|
171
|
+
try {
|
|
172
|
+
// check if name is provided
|
|
173
|
+
if (!dbName) {
|
|
174
|
+
return reply.status(400).send({
|
|
175
|
+
success: false,
|
|
176
|
+
message: "Database name is required",
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
// check if the database exists
|
|
180
|
+
const exists = yield this.AxioDBInstance.isDatabaseExists(dbName);
|
|
181
|
+
if (!exists) {
|
|
182
|
+
return reply.status(404).send({
|
|
183
|
+
success: false,
|
|
184
|
+
message: "Database not found",
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
// Get the current database path
|
|
188
|
+
const currDatabasePathData = `${this.AxioDBInstance.GetPath}/${dbName}`;
|
|
189
|
+
const responseZipTar = yield (0, ZipUnzip_utils_1.tarGzFolder)(currDatabasePathData, `./${dbName}.tar.gz`);
|
|
190
|
+
// Check if file was created and get its size
|
|
191
|
+
const fs = yield Promise.resolve().then(() => __importStar(require("fs")));
|
|
192
|
+
const stats = yield fs.promises.stat(responseZipTar);
|
|
193
|
+
if (stats.size === 0) {
|
|
194
|
+
yield fs.promises.unlink(responseZipTar);
|
|
195
|
+
return reply.status(500).send({
|
|
196
|
+
success: false,
|
|
197
|
+
message: "Generated export file is empty",
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
// Set headers
|
|
201
|
+
reply.header("Content-Type", "application/gzip");
|
|
202
|
+
reply.header("Content-Disposition", `attachment; filename="${dbName}.tar.gz"`);
|
|
203
|
+
reply.header("Content-Length", stats.size.toString());
|
|
204
|
+
const stream = fs.createReadStream(responseZipTar);
|
|
205
|
+
// Handle stream errors
|
|
206
|
+
stream.on("error", (error) => __awaiter(this, void 0, void 0, function* () {
|
|
207
|
+
console.error("Stream error:", error);
|
|
208
|
+
try {
|
|
209
|
+
yield fs.promises.unlink(responseZipTar);
|
|
210
|
+
}
|
|
211
|
+
catch (unlinkError) {
|
|
212
|
+
console.error("Error cleaning up temp file:", unlinkError);
|
|
213
|
+
}
|
|
214
|
+
}));
|
|
215
|
+
// Clean up after stream ends
|
|
216
|
+
stream.on("end", () => __awaiter(this, void 0, void 0, function* () {
|
|
217
|
+
try {
|
|
218
|
+
yield fs.promises.unlink(responseZipTar);
|
|
219
|
+
}
|
|
220
|
+
catch (unlinkError) {
|
|
221
|
+
console.error("Error cleaning up temp file:", unlinkError);
|
|
222
|
+
}
|
|
223
|
+
}));
|
|
224
|
+
return reply.send(stream);
|
|
225
|
+
}
|
|
226
|
+
catch (error) {
|
|
227
|
+
console.error("Error exporting database:", error);
|
|
228
|
+
return reply.status(500).send({
|
|
229
|
+
success: false,
|
|
230
|
+
message: "Error exporting database",
|
|
231
|
+
error: error instanceof Error ? error.message : String(error),
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Imports a database from an uploaded zip file.
|
|
238
|
+
*
|
|
239
|
+
* This method handles the upload of a database file, saves it temporarily,
|
|
240
|
+
* unzips it to the AxioDB instance path, and cleans up temporary files.
|
|
241
|
+
*
|
|
242
|
+
* @param request - The Fastify request object containing the uploaded file
|
|
243
|
+
* @param reply - The Fastify reply object for sending responses
|
|
244
|
+
* @returns A response object indicating success or failure of the import operation
|
|
245
|
+
* @throws Will handle errors related to file operations and return appropriate HTTP responses
|
|
246
|
+
*/
|
|
247
|
+
importDatabase(request, reply) {
|
|
248
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
249
|
+
const data = yield request.file(); // single file
|
|
250
|
+
if (!data) {
|
|
251
|
+
return reply.status(400).send({
|
|
252
|
+
success: false,
|
|
253
|
+
message: "No file uploaded",
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
// Create a Temporary Directory for Uploads
|
|
257
|
+
const tempDir = path_1.default.join(__dirname, "uploads");
|
|
258
|
+
yield fs_1.default.promises.mkdir(tempDir, { recursive: true });
|
|
259
|
+
const savePath = path_1.default.join(tempDir, data.filename);
|
|
260
|
+
yield fs_1.default.promises.writeFile(savePath, yield data.toBuffer());
|
|
261
|
+
const unzipped = yield (0, ZipUnzip_utils_1.unzipFile)(savePath, this.AxioDBInstance.GetPath);
|
|
262
|
+
// Check if unzipping was successful
|
|
263
|
+
if (!unzipped) {
|
|
264
|
+
return reply.status(500).send({
|
|
265
|
+
success: false,
|
|
266
|
+
message: "Error unzipping file",
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
// Remove the temporary directory
|
|
270
|
+
yield fs_1.default.promises.rmdir(tempDir, { recursive: true });
|
|
271
|
+
return { message: "File uploaded successfully", file: data.filename };
|
|
272
|
+
});
|
|
273
|
+
}
|
|
131
274
|
}
|
|
132
275
|
exports.default = DatabaseController;
|
|
133
276
|
//# sourceMappingURL=Databse.controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Databse.controller.js","sourceRoot":"","sources":["../../../../source/server/controller/Database/Databse.controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Databse.controller.js","sourceRoot":"","sources":["../../../../source/server/controller/Database/Databse.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAAuD;AACvD,mCAAqC;AAErC,iGAE6C;AAE7C,oEAAyE;AACzE,4CAAoB;AACpB,gDAAwB;AAExB;;;;;;GAMG;AACH,MAAqB,kBAAkB;IAGrC,YAAY,cAAsB;QAChC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;IAED;;;;;;;;;OASG;IACU,YAAY;;YACvB,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,eAAe,EAAE,CAAC;YAC9D,OAAO,IAAA,gCAAa,EAAC,oBAAW,CAAC,EAAE,EAAE,mBAAmB,EAAE,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,IAAI,CAAC,CAAC;QAC7E,CAAC;KAAA;IAED;;;;;;;;;OASG;IACU,cAAc,CACzB,OAAuB;;YAEvB,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,IAAwB,CAAC;YAElD,IAAI,CAAC;gBACH,uCAAuC;gBACvC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;gBAChE,IAAI,MAAM,EAAE,CAAC;oBACX,OAAO,IAAA,gCAAa,EAAC,oBAAW,CAAC,QAAQ,EAAE,yBAAyB,CAAC,CAAC;gBACxE,CAAC;gBACD,sBAAsB;gBACtB,IAAI,CAAC,IAAI,EAAE,CAAC;oBACV,OAAO,IAAA,gCAAa,EAClB,oBAAW,CAAC,WAAW,EACvB,2BAA2B,CAC5B,CAAC;gBACJ,CAAC;gBAED,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;oBACnD,OAAO,IAAA,gCAAa,EAAC,oBAAW,CAAC,WAAW,EAAE,uBAAuB,CAAC,CAAC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C,CAAC,CAAC;YACL,CAAC;YAED,iCAAiC;YACjC,MAAM,YAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAEtD,OAAO,EAAE,OAAO,EAAE,4BAA4B,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;QACxE,CAAC;KAAA;CACF;AAtPD,qCAsPC"}
|
|
@@ -16,7 +16,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
16
16
|
/* eslint-disable prefer-const */
|
|
17
17
|
const outers_1 = require("outers");
|
|
18
18
|
const responseBuilder_helper_1 = __importDefault(require("../../helper/responseBuilder.helper"));
|
|
19
|
-
const GlobalStorage_config_1 = __importDefault(require("../../config/GlobalStorage.config"));
|
|
20
19
|
/**
|
|
21
20
|
* CRUD Controller class for handling database operations
|
|
22
21
|
*/
|
|
@@ -218,7 +217,6 @@ class CRUDController {
|
|
|
218
217
|
if (!insertResult || insertResult.statusCode !== outers_1.StatusCodes.OK) {
|
|
219
218
|
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.INTERNAL_SERVER_ERROR, "Failed to insert document");
|
|
220
219
|
}
|
|
221
|
-
GlobalStorage_config_1.default.clear();
|
|
222
220
|
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.CREATED, "Document created successfully", insertResult.data);
|
|
223
221
|
});
|
|
224
222
|
}
|
|
@@ -260,7 +258,6 @@ class CRUDController {
|
|
|
260
258
|
if (!insertResult || insertResult.statusCode !== outers_1.StatusCodes.OK) {
|
|
261
259
|
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.INTERNAL_SERVER_ERROR, "Failed to insert document");
|
|
262
260
|
}
|
|
263
|
-
GlobalStorage_config_1.default.clear();
|
|
264
261
|
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.CREATED, "Document created successfully", insertResult.data);
|
|
265
262
|
});
|
|
266
263
|
}
|
|
@@ -300,7 +297,6 @@ class CRUDController {
|
|
|
300
297
|
if (!updateResult || updateResult.statusCode !== outers_1.StatusCodes.OK) {
|
|
301
298
|
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.INTERNAL_SERVER_ERROR, "Failed to update document");
|
|
302
299
|
}
|
|
303
|
-
GlobalStorage_config_1.default.clear();
|
|
304
300
|
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.OK, "Document updated successfully", updateResult.data);
|
|
305
301
|
});
|
|
306
302
|
}
|
|
@@ -349,7 +345,6 @@ class CRUDController {
|
|
|
349
345
|
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.INTERNAL_SERVER_ERROR, "Failed to update document");
|
|
350
346
|
}
|
|
351
347
|
}
|
|
352
|
-
GlobalStorage_config_1.default.clear();
|
|
353
348
|
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.OK, "Document updated successfully");
|
|
354
349
|
});
|
|
355
350
|
}
|
|
@@ -392,7 +387,6 @@ class CRUDController {
|
|
|
392
387
|
if (!deleteResult || deleteResult.statusCode !== outers_1.StatusCodes.OK) {
|
|
393
388
|
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.INTERNAL_SERVER_ERROR, "Failed to delete document");
|
|
394
389
|
}
|
|
395
|
-
GlobalStorage_config_1.default.clear();
|
|
396
390
|
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.OK, "Document deleted successfully");
|
|
397
391
|
});
|
|
398
392
|
}
|
|
@@ -438,13 +432,11 @@ class CRUDController {
|
|
|
438
432
|
}
|
|
439
433
|
else {
|
|
440
434
|
const deleteResult = yield DB_Collection.delete(query).deleteOne();
|
|
441
|
-
GlobalStorage_config_1.default.clear();
|
|
442
435
|
if (!deleteResult || deleteResult.statusCode !== outers_1.StatusCodes.OK) {
|
|
443
436
|
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.INTERNAL_SERVER_ERROR, "Failed to delete document");
|
|
444
437
|
}
|
|
445
438
|
}
|
|
446
439
|
}
|
|
447
|
-
GlobalStorage_config_1.default.clear();
|
|
448
440
|
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.OK, "Document deleted successfully");
|
|
449
441
|
});
|
|
450
442
|
}
|
|
@@ -484,7 +476,6 @@ class CRUDController {
|
|
|
484
476
|
if (!aggregationResult || aggregationResult.statusCode !== outers_1.StatusCodes.OK) {
|
|
485
477
|
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.INTERNAL_SERVER_ERROR, "Failed to run aggregation");
|
|
486
478
|
}
|
|
487
|
-
GlobalStorage_config_1.default.clear();
|
|
488
479
|
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.OK, "Aggregation run successfully", aggregationResult.data);
|
|
489
480
|
});
|
|
490
481
|
}
|