diff --git a/packages/core/src/operations.ts b/packages/core/src/operations.ts index 684ba74660..ff8e7406f5 100644 --- a/packages/core/src/operations.ts +++ b/packages/core/src/operations.ts @@ -1,5 +1,5 @@ import { deepEqual } from 'fast-equals' -import { DocumentUpdate, Hierarchy, MixinData, MixinUpdate, ModelDb, toFindResult } from '.' +import { DocumentUpdate, DOMAIN_MODEL, Hierarchy, MixinData, MixinUpdate, ModelDb, toFindResult } from '.' import type { Account, AnyAttribute, @@ -93,6 +93,9 @@ export class TxOperations implements Omit { if (hierarchy.isDerived(_class, core.class.AttachedDoc)) { throw new Error('createDoc cannot be used for objects inherited from AttachedDoc') } + if (hierarchy.findDomain(_class) === DOMAIN_MODEL && space !== core.space.Model) { + throw new Error('createDoc cannot be called for DOMAIN_MODEL classes with non-model space') + } const tx = this.txFactory.createTxCreateDoc(_class, space, attributes, id, modifiedOn, modifiedBy) await this.client.tx(tx) return tx.objectId