Process fixes (#10541)

* Process fixes

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>

* Some fixes

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>

---------

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov
2026-02-22 19:19:54 +07:00
committed by GitHub
parent f651c561b5
commit d51b68683a
19 changed files with 126 additions and 28 deletions
@@ -178,11 +178,14 @@ async function getRelationValue (
const q = context.direction === 'A' ? { docB: execution.card } : { docA: execution.card }
const relations = await control.client.findAll(core.class.Relation, { association: assoc._id, ...q })
const name = context.direction === 'A' ? assoc.nameA : assoc.nameB
if (relations.length === 0) throw processError(process.error.RelatedObjectNotFound, { attr: name })
const shouldBeArray = assoc.type === 'N:N' || (assoc.type === '1:N' && context.direction === 'A')
if (relations.length === 0) {
if (shouldBeArray) return []
throw processError(process.error.RelatedObjectNotFound, { attr: name })
}
const ids = relations.map((it) => {
return context.direction === 'A' ? it.docA : it.docB
})
const shouldBeArray = assoc.type === 'N:N' || (assoc.type === '1:N' && context.direction === 'A')
const target = await control.client.findAll(targetClass, { _id: { $in: ids } })
if (target.length === 0) throw processError(process.error.RelatedObjectNotFound, { attr: context.name })
const attr = context.key !== '' ? control.client.getHierarchy().findAttribute(targetClass, context.key) : undefined