codehooks-js 1.2.12 → 1.2.13
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/crudlify/index.mjs +9 -6
- package/package.json +1 -1
package/crudlify/index.mjs
CHANGED
|
@@ -213,8 +213,7 @@ async function updateFunc(req, res) {
|
|
|
213
213
|
document._id = ID; // put back id that was removed for validation
|
|
214
214
|
const conn = await Datastore.open();
|
|
215
215
|
await _eventHooks.fireBefore(collection, 'PUT', document);
|
|
216
|
-
const result = await conn.replaceOne(collection, ID, document, {});
|
|
217
|
-
console.debug('replaceOne result 1', result)
|
|
216
|
+
const result = await conn.replaceOne(collection, ID, document, {});
|
|
218
217
|
await _eventHooks.fireAfter(collection, 'PUT', result);
|
|
219
218
|
res.json(result);
|
|
220
219
|
})
|
|
@@ -226,16 +225,20 @@ async function updateFunc(req, res) {
|
|
|
226
225
|
document._id = ID; // put back id that was removed for validation
|
|
227
226
|
const conn = await Datastore.open();
|
|
228
227
|
await _eventHooks.fireBefore(collection, 'PUT', document);
|
|
229
|
-
const result = await conn.replaceOne(collection, ID, document, {});
|
|
230
|
-
console.debug('replaceOne result 2', result)
|
|
228
|
+
const result = await conn.replaceOne(collection, ID, document, {});
|
|
231
229
|
await _eventHooks.fireAfter(collection, 'PUT', result);
|
|
232
230
|
res.json(result);
|
|
233
231
|
}
|
|
234
232
|
} catch (e) {
|
|
235
|
-
|
|
236
|
-
|
|
233
|
+
if (e.schemaError) {
|
|
234
|
+
res
|
|
235
|
+
.status(400) // validator
|
|
236
|
+
.end(e);
|
|
237
|
+
} else {
|
|
238
|
+
res
|
|
237
239
|
.status(404) // not found
|
|
238
240
|
.end(e.message);
|
|
241
|
+
}
|
|
239
242
|
}
|
|
240
243
|
}
|
|
241
244
|
|