Skip to content

Commit 0cc917e

Browse files
committed
fix: internal clonesById is now a Ref
1 parent 7d58b05 commit 0cc917e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/modeling/use-model-instance.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import ObjectID from 'isomorphic-mongo-objectid'
2+
import type { Ref } from 'vue-demi'
23
import type { CloneOptions } from '../stores/index.js'
34
import type { AnyData, ById, Params } from '../types.js'
45
import { defineValues } from '../utils/define-properties'
56
import type { BaseModelData, ModelInstanceData, StoreInstanceProps } from './types.js'
67

78
interface UseModelInstanceOptions<M, Q extends AnyData> {
89
idField: string
9-
clonesById: ById<AnyData>
10+
clonesById: Ref<ById<AnyData>>
1011
clone: (item: M, data?: Record<string, any>, options?: CloneOptions) => M
1112
commit: (item: M, data?: Partial<M>) => M
1213
reset: (item: M, data?: Record<string, any>) => M
@@ -39,7 +40,7 @@ export function useModelInstance<M extends AnyData, Q extends AnyData>(data: Mod
3940
__tempId: data[idField] == null && data.__tempId == null ? new ObjectID().toString() : data.__tempId || undefined,
4041
hasClone(this: M) {
4142
const id = this[this.__idField] || this.__tempId
42-
const item = clonesById[id]
43+
const item = clonesById.value[id]
4344
return item || null
4445
},
4546
clone(this: M, data: Partial<M> = {}, options: CloneOptions = {}) {

0 commit comments

Comments
 (0)