@cocreate/crud-server 1.4.2 → 1.4.3
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 +5 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.4.3](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.4.2...v1.4.3) (2022-05-12)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* updateDocument now sends updated data ([f18d5e7](https://github.com/CoCreate-app/CoCreate-crud-server/commit/f18d5e7705658463326b276771825393603279e0))
|
|
7
|
+
|
|
1
8
|
## [1.4.2](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.4.1...v1.4.2) (2022-05-12)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/crud.js
CHANGED
|
@@ -66,11 +66,6 @@ class CoCreateCrud {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
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
|
-
}
|
|
74
69
|
if (!error && result && result.length > 0) {
|
|
75
70
|
let tmp = result[0];
|
|
76
71
|
if (req_data['exclude_fields']) {
|
|
@@ -117,8 +112,10 @@ class CoCreateCrud {
|
|
|
117
112
|
const update = {};
|
|
118
113
|
|
|
119
114
|
|
|
120
|
-
if( req_data['set'] )
|
|
121
|
-
|
|
115
|
+
if( req_data['set'] )
|
|
116
|
+
update['$set'] = replaceArray(req_data['set']);
|
|
117
|
+
if( req_data['unset'] )
|
|
118
|
+
update['$unset'] = req_data['unset'].reduce((r, d) => {r[d] = ""; return r}, {});
|
|
122
119
|
update['$set']['organization_id'] = req_data['organization_id'];
|
|
123
120
|
|
|
124
121
|
let projection = {}
|
|
@@ -135,7 +132,7 @@ class CoCreateCrud {
|
|
|
135
132
|
let isFlat = req_data.isFlat == true ? true : false;
|
|
136
133
|
let response_data = result.value || {};
|
|
137
134
|
|
|
138
|
-
let response = { ...req_data, document_id: response_data._id, data: isFlat ? encodeObject(
|
|
135
|
+
let response = { ...req_data, document_id: response_data._id, data: isFlat ? encodeObject(req_data['set']) : req_data['set'] };
|
|
139
136
|
|
|
140
137
|
if(req_data['unset']) response['delete_fields'] = req_data['unset'];
|
|
141
138
|
|