not-node 5.1.16 → 5.1.17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "not-node",
3
- "version": "5.1.16",
3
+ "version": "5.1.17",
4
4
  "description": "node complimentary part for client side notFramework.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -21,3 +21,10 @@ class DBExceptionDocumentIsNotOwnerByActiveUser extends notRequestError {
21
21
  }
22
22
  module.exports.DBExceptionDocumentIsNotOwnerByActiveUser =
23
23
  DBExceptionDocumentIsNotOwnerByActiveUser;
24
+
25
+ class DBExceptionDocumentIsNotFound extends notRequestError {
26
+ constructor({ params = {}, cause = null } = {}) {
27
+ super("DB document is not found", { code: 404, ...params }, cause);
28
+ }
29
+ }
30
+ module.exports.DBExceptionDocumentIsNotFound = DBExceptionDocumentIsNotFound;
@@ -1,7 +1,10 @@
1
1
  const { objHas, isFunc, executeFunctionAsAsync } = require("../common");
2
2
  const ModelRoutine = require("../model/routine");
3
3
  const { deleteResponseSuccess } = require("../model/utils.js");
4
- const { DBExceptionDeleteWasNotSuccessful } = require("../exceptions/db.js");
4
+ const {
5
+ DBExceptionDocumentIsNotFound,
6
+ DBExceptionDeleteWasNotSuccessful,
7
+ } = require("../exceptions/db.js");
5
8
  const {
6
9
  DBExceptionDocumentIsNotOwnerByActiveUser,
7
10
  } = require("../exceptions/http");
@@ -416,6 +419,9 @@ module.exports = ({
416
419
  const versioning = ModelRoutine.versioning(model);
417
420
  if (versioning) {
418
421
  let itm = await model.getOneRaw(targetId);
422
+ if (!itm) {
423
+ throw new DBExceptionDocumentIsNotFound();
424
+ }
419
425
  if (shouldOwn && !isOwner(itm, activeUser)) {
420
426
  throw new DBExceptionDocumentIsNotOwnerByActiveUser({
421
427
  params: {