@stonyx/orm 0.3.2-alpha.18 → 0.3.2-alpha.19

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.
@@ -38,4 +38,4 @@ export function getPendingRegistry() {
38
38
  export function getPendingBelongsToRegistry() {
39
39
  return relationships.get('pendingBelongsTo');
40
40
  }
41
- export const TYPES = ['global', 'hasMany', 'belongsTo', 'pending'];
41
+ export const TYPES = ['global', 'hasMany', 'belongsTo', 'pending', 'pendingBelongsTo'];
package/dist/store.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import Orm, { relationships } from '@stonyx/orm';
2
- import { TYPES, getHasManyRegistry, getBelongsToRegistry, getPendingRegistry } from './relationships.js';
2
+ import { TYPES, getHasManyRegistry, getBelongsToRegistry, getPendingRegistry, getPendingBelongsToRegistry } from './relationships.js';
3
3
  import ViewResolver from './view-resolver.js';
4
4
  function isStoreRecord(value) {
5
5
  return typeof value === 'object' && value !== null && '__data' in value;
@@ -264,6 +264,13 @@ export default class Store {
264
264
  const pendingMap = getPendingRegistry().get(modelName);
265
265
  if (pendingMap)
266
266
  pendingMap.delete(recordId);
267
+ const pendingBelongsToMap = getPendingBelongsToRegistry();
268
+ if (pendingBelongsToMap) {
269
+ // Clean entries where this model is the TARGET of a pending belongsTo
270
+ const targetEntries = pendingBelongsToMap.get(modelName);
271
+ if (targetEntries)
272
+ targetEntries.delete(recordId);
273
+ }
267
274
  }
268
275
  /**
269
276
  * Extracts hasMany and non-bidirectional belongsTo children from a record
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "stonyx-async",
5
5
  "stonyx-module"
6
6
  ],
7
- "version": "0.3.2-alpha.18",
7
+ "version": "0.3.2-alpha.19",
8
8
  "description": "",
9
9
  "main": "dist/index.js",
10
10
  "type": "module",
@@ -51,4 +51,4 @@ export function getPendingBelongsToRegistry(): PendingBelongsToMap {
51
51
  return relationships.get('pendingBelongsTo') as PendingBelongsToMap;
52
52
  }
53
53
 
54
- export const TYPES: string[] = ['global', 'hasMany', 'belongsTo', 'pending'];
54
+ export const TYPES: string[] = ['global', 'hasMany', 'belongsTo', 'pending', 'pendingBelongsTo'];
package/src/store.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Orm, { relationships } from '@stonyx/orm';
2
- import { TYPES, getHasManyRegistry, getBelongsToRegistry, getPendingRegistry } from './relationships.js';
2
+ import { TYPES, getHasManyRegistry, getBelongsToRegistry, getPendingRegistry, getPendingBelongsToRegistry } from './relationships.js';
3
3
  import ViewResolver from './view-resolver.js';
4
4
 
5
5
  interface UnloadOptions {
@@ -346,6 +346,13 @@ export default class Store {
346
346
 
347
347
  const pendingMap = getPendingRegistry().get(modelName);
348
348
  if (pendingMap) pendingMap.delete(recordId);
349
+
350
+ const pendingBelongsToMap = getPendingBelongsToRegistry();
351
+ if (pendingBelongsToMap) {
352
+ // Clean entries where this model is the TARGET of a pending belongsTo
353
+ const targetEntries = pendingBelongsToMap.get(modelName);
354
+ if (targetEntries) targetEntries.delete(recordId);
355
+ }
349
356
  }
350
357
 
351
358
  /**