mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-13 03:40:48 +00:00
throw error in case of non-model space for classes in model (#5694)
Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
parent
9903d9e7a7
commit
8d7406cbbb
@ -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<Client, 'notify'> {
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user