mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-14 12:25:17 +00:00
Make mongo working again (#405)
Signed-off-by: Andrey Platov <andrey@hardcoreeng.com> Co-authored-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
b73571be85
commit
3f62998052
@ -151,11 +151,6 @@ class MongoAdapter extends MongoAdapterBase {
|
|||||||
|
|
||||||
protected override async txUpdateDoc (tx: TxUpdateDoc<Doc>): Promise<TxResult> {
|
protected override async txUpdateDoc (tx: TxUpdateDoc<Doc>): Promise<TxResult> {
|
||||||
const domain = this.hierarchy.getDomain(tx.objectClass)
|
const domain = this.hierarchy.getDomain(tx.objectClass)
|
||||||
const operations = {
|
|
||||||
...tx.operations,
|
|
||||||
modifiedBy: tx.modifiedBy,
|
|
||||||
modifiedOn: tx.modifiedOn
|
|
||||||
}
|
|
||||||
if (isOperator(tx.operations)) {
|
if (isOperator(tx.operations)) {
|
||||||
const operator = Object.keys(tx.operations)[0]
|
const operator = Object.keys(tx.operations)[0]
|
||||||
if (operator === '$move') {
|
if (operator === '$move') {
|
||||||
@ -195,18 +190,30 @@ class MongoAdapter extends MongoAdapterBase {
|
|||||||
return await this.db.collection(domain).bulkWrite(ops as any)
|
return await this.db.collection(domain).bulkWrite(ops as any)
|
||||||
} else {
|
} else {
|
||||||
if (tx.retrieve === true) {
|
if (tx.retrieve === true) {
|
||||||
const result = await this.db.collection(domain).findOneAndUpdate({ _id: tx.objectId }, operations, { returnDocument: 'after' })
|
const result = await this.db.collection(domain).findOneAndUpdate({ _id: tx.objectId }, {
|
||||||
|
...tx.operations,
|
||||||
|
$set: {
|
||||||
|
modifiedBy: tx.modifiedBy,
|
||||||
|
modifiedOn: tx.modifiedOn
|
||||||
|
}
|
||||||
|
}, { returnDocument: 'after' })
|
||||||
return { object: result.value }
|
return { object: result.value }
|
||||||
} else {
|
} else {
|
||||||
return await this.db.collection(domain).updateOne({ _id: tx.objectId }, operations)
|
return await this.db.collection(domain).updateOne({ _id: tx.objectId }, {
|
||||||
|
...tx.operations,
|
||||||
|
$set: {
|
||||||
|
modifiedBy: tx.modifiedBy,
|
||||||
|
modifiedOn: tx.modifiedOn
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (tx.retrieve === true) {
|
if (tx.retrieve === true) {
|
||||||
const result = await this.db.collection(domain).findOneAndUpdate({ _id: tx.objectId }, { $set: operations }, { returnDocument: 'after' })
|
const result = await this.db.collection(domain).findOneAndUpdate({ _id: tx.objectId }, { $set: { ...tx.operations, modifiedBy: tx.modifiedBy, modifiedOn: tx.modifiedOn } }, { returnDocument: 'after' })
|
||||||
return { object: result.value }
|
return { object: result.value }
|
||||||
} else {
|
} else {
|
||||||
return await this.db.collection(domain).updateOne({ _id: tx.objectId }, { $set: operations })
|
return await this.db.collection(domain).updateOne({ _id: tx.objectId }, { $set: { ...tx.operations, modifiedBy: tx.modifiedBy, modifiedOn: tx.modifiedOn } })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user