Adding owner (for multiple enity association)
This commit is contained in:
@@ -40,7 +40,13 @@ module.exports = function (options) {
|
||||
userId: request.user.id,
|
||||
dialectId: translationArtifactVersion.dialectId,
|
||||
forkedFromId: translationArtifactVersion.id,
|
||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||
owner: {
|
||||
ownerEntities: [
|
||||
{
|
||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||
}
|
||||
]
|
||||
},
|
||||
translationChapters: translationArtifactVersion.translationChapters.map(translationChapter => {
|
||||
return {
|
||||
creatorId: request.user.id,
|
||||
@@ -73,6 +79,14 @@ module.exports = function (options) {
|
||||
association: db.TranslationChapter.TranslationChunks,
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.TranslationArtifactVersion.Owner,
|
||||
include: [
|
||||
{
|
||||
association: db.Owner.OwnerEntities
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
@@ -163,7 +177,24 @@ module.exports = function (options) {
|
||||
artifactVersionId: artifactVersion.id,
|
||||
dialectId: dialect.id,
|
||||
userId: userId,
|
||||
entityId: entityId
|
||||
owner: {
|
||||
ownerEntities: [
|
||||
{
|
||||
entityId: entityId,
|
||||
}
|
||||
]
|
||||
}
|
||||
}, {
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationArtifactVersion.Owner,
|
||||
include: [
|
||||
{
|
||||
association: db.Owner.OwnerEntities
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
} else {
|
||||
return db.TranslationArtifactVersion.create({
|
||||
@@ -172,7 +203,25 @@ module.exports = function (options) {
|
||||
artifactVersionId: artifactVersion.translationArtifactVersions[0].artifactVersionId,
|
||||
userId: userId,
|
||||
dialectId: artifactVersion.translationArtifactVersions[0].dialectId,
|
||||
forkedFromId: artifactVersion.translationArtifactVersions[0].id
|
||||
forkedFromId: artifactVersion.translationArtifactVersions[0].id,
|
||||
owner: {
|
||||
ownerEntities: [
|
||||
{
|
||||
entityId: entityId,
|
||||
}
|
||||
]
|
||||
}
|
||||
}, {
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationArtifactVersion.Owner,
|
||||
include: [
|
||||
{
|
||||
association: db.Owner.OwnerEntities
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user