@cocreate/crud-server 1.4.1 → 1.4.2
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 +7 -0
- package/package.json +1 -1
- package/src/crud.js +8 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.4.2](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.4.1...v1.4.2) (2022-05-12)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* createDocument requires organization_id to be stored ([259f56d](https://github.com/CoCreate-app/CoCreate-crud-server/commit/259f56daadc6b9e148f054c0ba2cf04443122a6a))
|
|
7
|
+
|
|
1
8
|
## [1.4.1](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.4.0...v1.4.1) (2022-05-06)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/crud.js
CHANGED
|
@@ -22,11 +22,12 @@ class CoCreateCrud {
|
|
|
22
22
|
async createDocument(socket, req_data, socketInfo){
|
|
23
23
|
const self = this;
|
|
24
24
|
if(!req_data.data) return;
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
try{
|
|
27
27
|
const db = this.dbClient.db(req_data['organization_id']);
|
|
28
28
|
const collection = db.collection(req_data["collection"]);
|
|
29
29
|
let insertData = replaceArray(req_data.data);
|
|
30
|
+
insertData['organization_id'] = req_data['organization_id'];
|
|
30
31
|
|
|
31
32
|
collection.insertOne(insertData, function(error, result) {
|
|
32
33
|
if(!error && result){
|
|
@@ -65,6 +66,11 @@ class CoCreateCrud {
|
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
collection.find(query).toArray(function(error, result) {
|
|
69
|
+
if (req_data["collection"] == 'test') {
|
|
70
|
+
console.log('query', query)
|
|
71
|
+
console.log('readDocument request', req_data)
|
|
72
|
+
console.log('readDocument result', result)
|
|
73
|
+
}
|
|
68
74
|
if (!error && result && result.length > 0) {
|
|
69
75
|
let tmp = result[0];
|
|
70
76
|
if (req_data['exclude_fields']) {
|
|
@@ -83,6 +89,7 @@ class CoCreateCrud {
|
|
|
83
89
|
let isFlat = req_data.isFlat == true ? true : false;
|
|
84
90
|
self.wsManager.send(socket, 'readDocument', { ...req_data, data: isFlat ? encodeObject(tmp) : tmp }, req_data['organization_id'], socketInfo);
|
|
85
91
|
} else {
|
|
92
|
+
console.log('readDocument error', error)
|
|
86
93
|
self.wsManager.send(socket, 'ServerError', error, null, socketInfo);
|
|
87
94
|
}
|
|
88
95
|
});
|