@cocreate/crud-server 1.4.1 → 1.4.4
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 +21 -0
- package/package.json +1 -1
- package/src/crud.js +10 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
## [1.4.4](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.4.3...v1.4.4) (2022-05-13)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* removed readDocument error console.log ([0ca8012](https://github.com/CoCreate-app/CoCreate-crud-server/commit/0ca8012b3f9e1d2efccdfb4216bf1ccfe430b026))
|
|
7
|
+
|
|
8
|
+
## [1.4.3](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.4.2...v1.4.3) (2022-05-12)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* updateDocument now sends updated data ([f18d5e7](https://github.com/CoCreate-app/CoCreate-crud-server/commit/f18d5e7705658463326b276771825393603279e0))
|
|
14
|
+
|
|
15
|
+
## [1.4.2](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.4.1...v1.4.2) (2022-05-12)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* createDocument requires organization_id to be stored ([259f56d](https://github.com/CoCreate-app/CoCreate-crud-server/commit/259f56daadc6b9e148f054c0ba2cf04443122a6a))
|
|
21
|
+
|
|
1
22
|
## [1.4.1](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.4.0...v1.4.1) (2022-05-06)
|
|
2
23
|
|
|
3
24
|
|
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){
|
|
@@ -87,7 +88,7 @@ class CoCreateCrud {
|
|
|
87
88
|
}
|
|
88
89
|
});
|
|
89
90
|
} catch (error) {
|
|
90
|
-
console.log('readDocument error', error);
|
|
91
|
+
console.log('readDocument error', error, req_data);
|
|
91
92
|
self.wsManager.send(socket, 'ServerError', 'error', null, socketInfo);
|
|
92
93
|
}
|
|
93
94
|
}
|
|
@@ -110,8 +111,10 @@ class CoCreateCrud {
|
|
|
110
111
|
const update = {};
|
|
111
112
|
|
|
112
113
|
|
|
113
|
-
if( req_data['set'] )
|
|
114
|
-
|
|
114
|
+
if( req_data['set'] )
|
|
115
|
+
update['$set'] = replaceArray(req_data['set']);
|
|
116
|
+
if( req_data['unset'] )
|
|
117
|
+
update['$unset'] = req_data['unset'].reduce((r, d) => {r[d] = ""; return r}, {});
|
|
115
118
|
update['$set']['organization_id'] = req_data['organization_id'];
|
|
116
119
|
|
|
117
120
|
let projection = {}
|
|
@@ -128,9 +131,10 @@ class CoCreateCrud {
|
|
|
128
131
|
let isFlat = req_data.isFlat == true ? true : false;
|
|
129
132
|
let response_data = result.value || {};
|
|
130
133
|
|
|
131
|
-
let response = { ...req_data, document_id: response_data._id, data: isFlat ? encodeObject(
|
|
134
|
+
let response = { ...req_data, document_id: response_data._id, data: isFlat ? encodeObject(req_data['set']) : req_data['set'] };
|
|
132
135
|
|
|
133
|
-
if(req_data['unset'])
|
|
136
|
+
if(req_data['unset'])
|
|
137
|
+
response['delete_fields'] = req_data['unset'];
|
|
134
138
|
|
|
135
139
|
self.broadcast('updateDocument', socket, response, socketInfo)
|
|
136
140
|
}).catch((error) => {
|