mirror of
https://github.com/overleaf/overleaf.git
synced 2025-03-22 02:04:31 +00:00
Merge pull request #2502 from overleaf/sk-fix-mongoose-push-all
Tell mongoose to set `usePushEach` on all models GitOrigin-RevId: faea6653f272f74ea7274596bdc934ef93638d76
This commit is contained in:
parent
358ab03e32
commit
2826832c5e
5 changed files with 42 additions and 6 deletions
|
@ -126,18 +126,32 @@ async function transferProjects(fromUserId, toUserId) {
|
|||
{ $set: { owner_ref: toUserId } },
|
||||
{ multi: true }
|
||||
).exec()
|
||||
|
||||
await Project.update(
|
||||
{ collaberator_refs: fromUserId },
|
||||
{
|
||||
$addToSet: { collaberator_refs: toUserId }
|
||||
},
|
||||
{ multi: true }
|
||||
).exec()
|
||||
await Project.update(
|
||||
{ collaberator_refs: fromUserId },
|
||||
{
|
||||
$addToSet: { collaberator_refs: toUserId },
|
||||
$pull: { collaberator_refs: fromUserId }
|
||||
},
|
||||
{ multi: true }
|
||||
).exec()
|
||||
|
||||
await Project.update(
|
||||
{ readOnly_refs: fromUserId },
|
||||
{
|
||||
$addToSet: { readOnly_refs: toUserId }
|
||||
},
|
||||
{ multi: true }
|
||||
).exec()
|
||||
await Project.update(
|
||||
{ readOnly_refs: fromUserId },
|
||||
{
|
||||
$addToSet: { readOnly_refs: toUserId },
|
||||
$pull: { readOnly_refs: fromUserId }
|
||||
},
|
||||
{ multi: true }
|
||||
|
|
|
@ -38,4 +38,8 @@ if (process.env.MONGOOSE_DEBUG) {
|
|||
)
|
||||
}
|
||||
|
||||
mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true
|
||||
})
|
||||
|
||||
module.exports = mongoose
|
||||
|
|
|
@ -54,4 +54,4 @@ services:
|
|||
image: redis
|
||||
|
||||
mongo:
|
||||
image: mongo:3.4.6
|
||||
image: mongo:3.6.16
|
||||
|
|
|
@ -49,4 +49,4 @@ services:
|
|||
image: redis
|
||||
|
||||
mongo:
|
||||
image: mongo:3.4.6
|
||||
image: mongo:3.6.16
|
||||
|
|
|
@ -297,7 +297,16 @@ describe('CollaboratorsHandler', function() {
|
|||
.withArgs(
|
||||
{ collaberator_refs: this.fromUserId },
|
||||
{
|
||||
$addToSet: { collaberator_refs: this.toUserId },
|
||||
$addToSet: { collaberator_refs: this.toUserId }
|
||||
},
|
||||
{ multi: true }
|
||||
)
|
||||
.chain('exec')
|
||||
.resolves()
|
||||
this.ProjectMock.expects('update')
|
||||
.withArgs(
|
||||
{ collaberator_refs: this.fromUserId },
|
||||
{
|
||||
$pull: { collaberator_refs: this.fromUserId }
|
||||
},
|
||||
{ multi: true }
|
||||
|
@ -308,7 +317,16 @@ describe('CollaboratorsHandler', function() {
|
|||
.withArgs(
|
||||
{ readOnly_refs: this.fromUserId },
|
||||
{
|
||||
$addToSet: { readOnly_refs: this.toUserId },
|
||||
$addToSet: { readOnly_refs: this.toUserId }
|
||||
},
|
||||
{ multi: true }
|
||||
)
|
||||
.chain('exec')
|
||||
.resolves()
|
||||
this.ProjectMock.expects('update')
|
||||
.withArgs(
|
||||
{ readOnly_refs: this.fromUserId },
|
||||
{
|
||||
$pull: { readOnly_refs: this.fromUserId }
|
||||
},
|
||||
{ multi: true }
|
||||
|
|
Loading…
Reference in a new issue