@cocreate/crud-server 1.11.0 → 1.12.0
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/CHANGELOG.md +19 -0
- package/package.json +2 -2
- package/src/crud.js +12 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
# [1.12.0](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.11.1...v1.12.0) (2022-10-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* bump dependencies ([702bf69](https://github.com/CoCreate-app/CoCreate-crud-server/commit/702bf6960c6efc9563e923325cc03ba2f1e842df))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* support for operator $contain and $regex ([fb7d4a5](https://github.com/CoCreate-app/CoCreate-crud-server/commit/fb7d4a5508c0ca75100ba40305196ed2b7ea7d6b))
|
|
12
|
+
|
|
13
|
+
## [1.11.1](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.11.0...v1.11.1) (2022-10-01)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* bump [@cocreate](https://github.com/cocreate) dependencies ([12a2ae4](https://github.com/CoCreate-app/CoCreate-crud-server/commit/12a2ae454f0b12424f4c072b9dd2b31e02c20ade))
|
|
19
|
+
|
|
1
20
|
# [1.11.0](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.10.1...v1.11.0) (2022-10-01)
|
|
2
21
|
|
|
3
22
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/crud-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
4
4
|
"description": "CoCreate-crud-server",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cocreate-crud",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
"homepage": "https://cocreate.app/docs/CoCreate-crud-server",
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@cocreate/docs": "^1.3.
|
|
43
|
+
"@cocreate/docs": "^1.3.18",
|
|
44
44
|
"csvtojson": "^2.0.10",
|
|
45
45
|
"json-2-csv": "^3.10.3",
|
|
46
46
|
"mongodb": "^4.4.0"
|
package/src/crud.js
CHANGED
|
@@ -195,6 +195,7 @@ class CoCreateCrud {
|
|
|
195
195
|
const db = this.dbClient.db(data['organization_id']);
|
|
196
196
|
const collection = db.collection(data["collection"]);
|
|
197
197
|
let {query, sort} = this.getFilters(data);
|
|
198
|
+
|
|
198
199
|
collection.find(query).sort(sort).toArray(function(error, result) {
|
|
199
200
|
if (result) {
|
|
200
201
|
data['data'] = searchData(result, data.filter)
|
|
@@ -314,6 +315,7 @@ class CoCreateCrud {
|
|
|
314
315
|
return {query, sort}
|
|
315
316
|
}
|
|
316
317
|
|
|
318
|
+
// ToDo: create impved mongodb query to cover many cases
|
|
317
319
|
createQuery(filters, data) {
|
|
318
320
|
let query = new Object();
|
|
319
321
|
|
|
@@ -331,12 +333,7 @@ class CoCreateCrud {
|
|
|
331
333
|
|
|
332
334
|
switch (item.operator) {
|
|
333
335
|
case '$contain':
|
|
334
|
-
|
|
335
|
-
item.value.forEach(function(v) {
|
|
336
|
-
in_values.push(new RegExp(".*" + v + ".*", "i"));
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
query[key] = {$in : in_values }
|
|
336
|
+
query[key]['$regex'] = item.value;
|
|
340
337
|
break;
|
|
341
338
|
|
|
342
339
|
case '$range':
|
|
@@ -355,9 +352,17 @@ class CoCreateCrud {
|
|
|
355
352
|
case '$lte':
|
|
356
353
|
case '$gt':
|
|
357
354
|
case '$gte':
|
|
358
|
-
|
|
355
|
+
case '$regex':
|
|
356
|
+
query[key][item.operator] = item.value;
|
|
359
357
|
break;
|
|
360
358
|
case '$in':
|
|
359
|
+
var in_values = [];
|
|
360
|
+
item.value.forEach(function(v) {
|
|
361
|
+
in_values.push(new RegExp(".*" + v + ".*", "i"));
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
query[key] = {$in : in_values }
|
|
365
|
+
break;
|
|
361
366
|
case '$nin':
|
|
362
367
|
query[key][item.operator] = item.value;
|
|
363
368
|
break;
|