@cocreate/crud-server 1.3.0 → 1.3.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 +21 -0
- package/package.json +1 -1
- package/src/crud.js +11 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
## [1.3.3](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.3.2...v1.3.3) (2022-03-05)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* typo reponse to response ([bbc67bf](https://github.com/CoCreate-app/CoCreate-crud-server/commit/bbc67bf99652175a3a9f6ccbdd7cd08cf5a536ba))
|
|
7
|
+
|
|
8
|
+
## [1.3.2](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.3.1...v1.3.2) (2022-03-04)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* add self.wsManager ([537375e](https://github.com/CoCreate-app/CoCreate-crud-server/commit/537375ec182242ff012f0ed11a6d3fe5f905ff26))
|
|
14
|
+
|
|
15
|
+
## [1.3.1](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.3.0...v1.3.1) (2022-03-04)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* bump version ([3b7adce](https://github.com/CoCreate-app/CoCreate-crud-server/commit/3b7adcef74cf426dc34d723478c44360a6f28219))
|
|
21
|
+
|
|
1
22
|
# [1.3.0](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.2.10...v1.3.0) (2022-03-03)
|
|
2
23
|
|
|
3
24
|
|
package/package.json
CHANGED
package/src/crud.js
CHANGED
|
@@ -33,15 +33,15 @@ class CoCreateCrud {
|
|
|
33
33
|
const response = {...req_data, document_id: result.ops[0]._id, data:result.ops[0] }
|
|
34
34
|
// let isFlat = req_data.isFlat == false ? false : true;
|
|
35
35
|
// const response_data = isFlat ? encodeObject(response) : response;
|
|
36
|
-
const response_data = response;
|
|
37
|
-
self.broadcast('createDocument', socket, req_data, roomInfo)
|
|
36
|
+
// const response_data = response;
|
|
37
|
+
self.broadcast('createDocument', socket, req_data, response, roomInfo)
|
|
38
38
|
} else {
|
|
39
39
|
self.wsManager.send(socket, 'ServerError', error, null, roomInfo);
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
}catch(error){
|
|
43
43
|
console.log('createDocument error', error);
|
|
44
|
-
|
|
44
|
+
self.wsManager.send(socket, 'ServerError', 'error', null, roomInfo);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -88,14 +88,13 @@ class CoCreateCrud {
|
|
|
88
88
|
});
|
|
89
89
|
} catch (error) {
|
|
90
90
|
console.log('readDocument error', error);
|
|
91
|
-
|
|
91
|
+
self.wsManager.send(socket, 'ServerError', 'error', null, roomInfo);
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
/** Update Document **/
|
|
96
96
|
async updateDocument(socket, req_data, roomInfo) {
|
|
97
97
|
const self = this;
|
|
98
|
-
|
|
99
98
|
try {
|
|
100
99
|
const db = this.dbClient.db(req_data['organization_id']);
|
|
101
100
|
const collection = db.collection(req_data["collection"]);
|
|
@@ -108,7 +107,6 @@ class CoCreateCrud {
|
|
|
108
107
|
console.log(err);
|
|
109
108
|
}
|
|
110
109
|
const query = {"_id": objId };
|
|
111
|
-
|
|
112
110
|
const update = {};
|
|
113
111
|
|
|
114
112
|
|
|
@@ -127,7 +125,6 @@ class CoCreateCrud {
|
|
|
127
125
|
projection: projection,
|
|
128
126
|
}
|
|
129
127
|
).then((result) => {
|
|
130
|
-
|
|
131
128
|
let isFlat = req_data.isFlat == true ? true : false;
|
|
132
129
|
let response_data = result.value || {};
|
|
133
130
|
|
|
@@ -135,8 +132,9 @@ class CoCreateCrud {
|
|
|
135
132
|
|
|
136
133
|
if(req_data['unset']) response['delete_fields'] = req_data['unset'];
|
|
137
134
|
|
|
138
|
-
self.broadcast('updateDocument', socket, req_data, roomInfo)
|
|
135
|
+
self.broadcast('updateDocument', socket, req_data, response, roomInfo)
|
|
139
136
|
}).catch((error) => {
|
|
137
|
+
console.log('error', error)
|
|
140
138
|
self.wsManager.send(socket, 'ServerError', error, null, roomInfo);
|
|
141
139
|
});
|
|
142
140
|
|
|
@@ -160,27 +158,27 @@ class CoCreateCrud {
|
|
|
160
158
|
collection.deleteOne(query, function(error, result) {
|
|
161
159
|
if (!error) {
|
|
162
160
|
let response = { ...req_data }
|
|
163
|
-
self.broadcast('deleteDocument', socket, req_data, roomInfo)
|
|
161
|
+
self.broadcast('deleteDocument', socket, req_data, response, roomInfo)
|
|
164
162
|
} else {
|
|
165
163
|
self.wsManager.send(socket, 'ServerError', error, null, roomInfo);
|
|
166
164
|
}
|
|
167
165
|
})
|
|
168
166
|
} catch (error) {
|
|
169
167
|
console.log(error);
|
|
170
|
-
|
|
168
|
+
self.wsManager.send(socket, 'ServerError', 'error', null, roomInfo);
|
|
171
169
|
}
|
|
172
170
|
}
|
|
173
171
|
|
|
174
172
|
broadcast(component, socket, req_data, response, roomInfo) {
|
|
175
173
|
if (req_data.broadcast_sender != false) {
|
|
176
|
-
|
|
174
|
+
this.wsManager.send(socket, component, { ...response, element: req_data['element']}, req_data['organization_id'], roomInfo);
|
|
177
175
|
}
|
|
178
176
|
|
|
179
177
|
if (req_data.broadcast !== false) {
|
|
180
178
|
if (req_data.room) {
|
|
181
|
-
|
|
179
|
+
this.wsManager.broadcast(socket, req_data.namespace || req_data['organization_id'] , req_data.room, component, response, true, roomInfo);
|
|
182
180
|
} else {
|
|
183
|
-
|
|
181
|
+
this.wsManager.broadcast(socket, req_data.namespace || req_data['organization_id'], null, component, response, true, roomInfo)
|
|
184
182
|
}
|
|
185
183
|
}
|
|
186
184
|
process.emit('changed-document', response)
|