mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-29 21:15:06 +02:00
Add relation action (#9970)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
@@ -120,7 +120,7 @@ export async function AddRelation (
|
||||
params: MethodParams<Relation>,
|
||||
execution: Execution,
|
||||
control: ProcessControl
|
||||
): Promise<ExecuteResult | undefined> {
|
||||
): Promise<ExecuteResult> {
|
||||
const _id = generateId<Relation>()
|
||||
const association = params.association as Ref<Association>
|
||||
if (isEmpty(association)) {
|
||||
@@ -141,6 +141,14 @@ export async function AddRelation (
|
||||
docA,
|
||||
docB
|
||||
}
|
||||
const exists = await control.client.findOne(core.class.Relation, { docA, docB, association })
|
||||
if (exists !== undefined) {
|
||||
return {
|
||||
txes: [],
|
||||
rollback: [],
|
||||
context: []
|
||||
}
|
||||
}
|
||||
const resTx = control.client.txFactory.createTxCreateDoc(core.class.Relation, core.space.Workspace, data, _id)
|
||||
const res: Tx[] = [resTx]
|
||||
const rollback: Tx[] = [control.client.txFactory.createTxRemoveDoc(core.class.Relation, core.space.Workspace, _id)]
|
||||
|
||||
Reference in New Issue
Block a user