@dnax/core 0.49.0 → 0.50.1

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.
@@ -816,7 +816,11 @@ class useRest {
816
816
  options?: Omit<optionCb, "elementAt">
817
817
  ): Promise<object | null> {
818
818
  return new Promise(async (resolve, reject) => {
819
- if (!id) fn.error("Id is required", 400);
819
+ if (!id)
820
+ return reject({
821
+ code: 400,
822
+ message: "Id required",
823
+ });
820
824
  try {
821
825
  let meta = {
822
826
  total: 0,
@@ -1009,6 +1013,12 @@ class useRest {
1009
1013
  return resolve(result);
1010
1014
  }
1011
1015
 
1016
+ if (!id)
1017
+ return reject({
1018
+ code: 400,
1019
+ message: "Id required",
1020
+ });
1021
+
1012
1022
  //@ts-expect-error
1013
1023
  update = omit(update, omitUpdate);
1014
1024
 
@@ -1340,7 +1350,11 @@ class useRest {
1340
1350
  }
1341
1351
 
1342
1352
  if (Array.isArray(ids)) {
1343
- if (!ids?.length) throw new contextError("List of id required", 400);
1353
+ if (!ids?.length)
1354
+ return reject({
1355
+ code: 400,
1356
+ message: "Ids required",
1357
+ });
1344
1358
 
1345
1359
  await this.#tenant.database.db?.collection(collection).updateMany(
1346
1360
  {
@@ -1420,7 +1434,6 @@ class useRest {
1420
1434
  ): Promise<object> {
1421
1435
  return new Promise(async (resolve, reject) => {
1422
1436
  try {
1423
- if (!id) fn.error("Id is required", 400);
1424
1437
  let useHook = options?.useHook ?? this.#useHook;
1425
1438
  let useCustomApi = options?.useCustomApi ?? this.#useCustomApi;
1426
1439
 
@@ -1473,6 +1486,11 @@ class useRest {
1473
1486
  });
1474
1487
  return resolve(result!);
1475
1488
  }
1489
+ if (!id)
1490
+ return reject({
1491
+ code: 400,
1492
+ message: "Id required",
1493
+ });
1476
1494
 
1477
1495
  let doc = await this.#tenant.database.db
1478
1496
  ?.collection(collection)
@@ -1583,7 +1601,11 @@ class useRest {
1583
1601
 
1584
1602
  let deletedIds: any = ids || [];
1585
1603
 
1586
- if (!ids) fn.error("List of id required", 400);
1604
+ if (!ids)
1605
+ return reject({
1606
+ code: 400,
1607
+ message: "Ids required",
1608
+ });
1587
1609
 
1588
1610
  if (Array.isArray(ids)) {
1589
1611
  await this.#tenant.database.db?.collection(collection).deleteMany(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnax/core",
3
- "version": "0.49.0",
3
+ "version": "0.50.1",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "bin": {