spice-js 2.7.24 → 2.7.26

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.
@@ -696,6 +696,9 @@ class SpiceModel {
696
696
  try {
697
697
  if (_.isString(data)) {
698
698
  var result = yield _this7.database.get(data);
699
+ if (!result) {
700
+ return false;
701
+ }
699
702
  if (result.type) if (result.type != _this7.type) {
700
703
  return false;
701
704
  }
@@ -703,6 +706,9 @@ class SpiceModel {
703
706
  return false;
704
707
  }
705
708
  } else {
709
+ if (!data) {
710
+ return false;
711
+ }
706
712
  if (data.type) if (data.type != _this7.type) {
707
713
  return false;
708
714
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spice-js",
3
- "version": "2.7.24",
3
+ "version": "2.7.26",
4
4
  "description": "spice",
5
5
  "main": "build/index.js",
6
6
  "repository": {
@@ -762,6 +762,9 @@ export default class SpiceModel {
762
762
  try {
763
763
  if (_.isString(data)) {
764
764
  let result = await this.database.get(data);
765
+ if (!result) {
766
+ return false;
767
+ }
765
768
  if (result.type)
766
769
  if (result.type != this.type) {
767
770
  return false;
@@ -771,6 +774,9 @@ export default class SpiceModel {
771
774
  return false;
772
775
  }
773
776
  } else {
777
+ if (!data) {
778
+ return false;
779
+ }
774
780
  if (data.type)
775
781
  if (data.type != this.type) {
776
782
  return false;
@@ -32,6 +32,18 @@ class MockDatabase {
32
32
  return this.mockData.get(id);
33
33
  }
34
34
 
35
+ /**
36
+ * Mock update operation
37
+ * @param {string} id - Document ID to update
38
+ * @param {Object} data - Updated document data
39
+ * @returns {Promise<Object>} Updated document
40
+ */
41
+ async update(id, data, ttl) {
42
+ const updated = { ...data, id };
43
+ this.mockData.set(id, updated);
44
+ return updated;
45
+ }
46
+
35
47
  /**
36
48
  * Seed mock database with test data
37
49
  * @param {string} id - Document ID
@@ -578,6 +578,12 @@ describe('SpiceModel - Critical Fixes for Empty/Null Values', () => {
578
578
  model = createTestModel({ type: 'user' });
579
579
  });
580
580
 
581
+ test('should fail update with a controlled not-found error when database returns undefined', async () => {
582
+ await expect(
583
+ model.update({ id: 'missing-user' })
584
+ ).rejects.toThrow('user does not exist. in update');
585
+ });
586
+
581
587
  test('should handle undefined columns parameter', async () => {
582
588
  seedDatabase(model, sampleDbResults.users);
583
589