Merge pull request #3277 from overleaf/revert-3257-jpa-mongoose-latest
Revert "[misc] upgrade mongoose to the latest version" GitOrigin-RevId: d5957fca68be65a08a687476742ffbb9c3cb86e8
This commit is contained in:
committed by
Copybot
parent
dba5127856
commit
c257b9695a
@@ -96,7 +96,7 @@ module.exports = ProjectCollabratecDetailsHandler = {
|
||||
}
|
||||
}
|
||||
}
|
||||
return Project.updateOne(query, update, callback)
|
||||
return Project.update(query, update, callback)
|
||||
},
|
||||
|
||||
setCollabratecUsers(project_id, collabratec_users, callback) {
|
||||
@@ -122,7 +122,7 @@ module.exports = ProjectCollabratecDetailsHandler = {
|
||||
}
|
||||
}
|
||||
const update = { $set: { collabratecUsers: collabratec_users } }
|
||||
return Project.updateOne({ _id: project_id }, update, callback)
|
||||
return Project.update({ _id: project_id }, update, callback)
|
||||
},
|
||||
|
||||
unlinkCollabratecUserProject(project_id, user_id, callback) {
|
||||
@@ -144,7 +144,7 @@ module.exports = ProjectCollabratecDetailsHandler = {
|
||||
}
|
||||
}
|
||||
}
|
||||
return Project.updateOne(query, update, callback)
|
||||
return Project.update(query, update, callback)
|
||||
},
|
||||
|
||||
updateCollabratecUserIds(old_user_id, new_user_id, callback) {
|
||||
@@ -160,6 +160,7 @@ module.exports = ProjectCollabratecDetailsHandler = {
|
||||
}
|
||||
const query = { 'collabratecUsers.user_id': old_user_id }
|
||||
const update = { $set: { 'collabratecUsers.$.user_id': new_user_id } }
|
||||
return Project.updateMany(query, update, callback)
|
||||
const options = { multi: true }
|
||||
return Project.update(query, update, options, callback)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ async function markAsDeletedByExternalSource(projectId) {
|
||||
{ project_id: projectId },
|
||||
'marking project as deleted by external data source'
|
||||
)
|
||||
await Project.updateOne(
|
||||
await Project.update(
|
||||
{ _id: projectId },
|
||||
{ deletedByExternalDataSource: true }
|
||||
).exec()
|
||||
@@ -68,7 +68,7 @@ async function markAsDeletedByExternalSource(projectId) {
|
||||
}
|
||||
|
||||
async function unmarkAsDeletedByExternalSource(projectId) {
|
||||
await Project.updateOne(
|
||||
await Project.update(
|
||||
{ _id: projectId },
|
||||
{ deletedByExternalDataSource: false }
|
||||
).exec()
|
||||
@@ -101,7 +101,7 @@ async function expireDeletedProjectsAfterDuration() {
|
||||
}
|
||||
|
||||
async function restoreProject(projectId) {
|
||||
await Project.updateOne(
|
||||
await Project.update(
|
||||
{ _id: projectId },
|
||||
{ $unset: { archived: true } }
|
||||
).exec()
|
||||
@@ -119,7 +119,7 @@ async function archiveProject(projectId, userId) {
|
||||
'ARCHIVE'
|
||||
)
|
||||
|
||||
await Project.updateOne(
|
||||
await Project.update(
|
||||
{ _id: projectId },
|
||||
{ $set: { archived: archived }, $pull: { trashed: ObjectId(userId) } }
|
||||
)
|
||||
@@ -142,10 +142,7 @@ async function unarchiveProject(projectId, userId) {
|
||||
'UNARCHIVE'
|
||||
)
|
||||
|
||||
await Project.updateOne(
|
||||
{ _id: projectId },
|
||||
{ $set: { archived: archived } }
|
||||
)
|
||||
await Project.update({ _id: projectId }, { $set: { archived: archived } })
|
||||
} catch (err) {
|
||||
logger.warn({ err }, 'problem unarchiving project')
|
||||
throw err
|
||||
@@ -165,7 +162,7 @@ async function trashProject(projectId, userId) {
|
||||
'UNARCHIVE'
|
||||
)
|
||||
|
||||
await Project.updateOne(
|
||||
await Project.update(
|
||||
{ _id: projectId },
|
||||
{
|
||||
$addToSet: { trashed: ObjectId(userId) },
|
||||
@@ -185,7 +182,7 @@ async function untrashProject(projectId, userId) {
|
||||
throw new Errors.NotFoundError('project not found')
|
||||
}
|
||||
|
||||
await Project.updateOne(
|
||||
await Project.update(
|
||||
{ _id: projectId },
|
||||
{ $pull: { trashed: ObjectId(userId) } }
|
||||
)
|
||||
@@ -230,7 +227,7 @@ async function deleteProject(projectId, options = {}) {
|
||||
key => (deleterData[key] === undefined ? delete deleterData[key] : '')
|
||||
)
|
||||
|
||||
await DeletedProject.updateOne(
|
||||
await DeletedProject.update(
|
||||
{ 'deleterData.deletedProjectId': projectId },
|
||||
{ project, deleterData },
|
||||
{ upsert: true }
|
||||
@@ -254,7 +251,7 @@ async function deleteProject(projectId, options = {}) {
|
||||
})
|
||||
}
|
||||
|
||||
await Project.deleteOne({ _id: projectId }).exec()
|
||||
await Project.remove({ _id: projectId }).exec()
|
||||
} catch (err) {
|
||||
logger.warn({ err }, 'problem deleting project')
|
||||
throw err
|
||||
@@ -319,7 +316,7 @@ async function expireDeletedProject(projectId) {
|
||||
await HistoryManager.promises.deleteProject(deletedProject.project._id)
|
||||
await FilestoreHandler.promises.deleteProject(deletedProject.project._id)
|
||||
|
||||
await DeletedProject.updateOne(
|
||||
await DeletedProject.update(
|
||||
{
|
||||
_id: deletedProject._id
|
||||
},
|
||||
|
||||
@@ -90,7 +90,7 @@ async function setProjectDescription(projectId, description) {
|
||||
'setting project description'
|
||||
)
|
||||
try {
|
||||
await Project.updateOne(conditions, update).exec()
|
||||
await Project.update(conditions, update).exec()
|
||||
} catch (err) {
|
||||
logger.warn({ err }, 'something went wrong setting project description')
|
||||
throw err
|
||||
@@ -111,7 +111,7 @@ async function renameProject(projectId, newName) {
|
||||
return
|
||||
}
|
||||
const oldProjectName = project.name
|
||||
await Project.updateOne({ _id: projectId }, { name: newName }).exec()
|
||||
await Project.update({ _id: projectId }, { name: newName }).exec()
|
||||
await TpdsUpdateSender.promises.moveEntity({
|
||||
project_id: projectId,
|
||||
project_name: oldProjectName,
|
||||
@@ -197,7 +197,7 @@ async function setPublicAccessLevel(projectId, newAccessLevel) {
|
||||
newAccessLevel
|
||||
)
|
||||
) {
|
||||
await Project.updateOne(
|
||||
await Project.update(
|
||||
{ _id: projectId },
|
||||
{ publicAccesLevel: newAccessLevel }
|
||||
).exec()
|
||||
@@ -216,7 +216,7 @@ async function ensureTokensArePresent(projectId) {
|
||||
return project.tokens
|
||||
}
|
||||
await _generateTokens(project)
|
||||
await Project.updateOne(
|
||||
await Project.update(
|
||||
{ _id: projectId },
|
||||
{ $set: { tokens: project.tokens } }
|
||||
).exec()
|
||||
@@ -224,7 +224,7 @@ async function ensureTokensArePresent(projectId) {
|
||||
}
|
||||
|
||||
async function clearTokens(projectId) {
|
||||
await Project.updateOne(
|
||||
await Project.update(
|
||||
{ _id: projectId },
|
||||
{ $unset: { tokens: 1 }, $set: { publicAccesLevel: 'private' } }
|
||||
).exec()
|
||||
|
||||
@@ -182,7 +182,7 @@ const ProjectEntityUpdateHandler = {
|
||||
return callback(err)
|
||||
}
|
||||
if (ProjectEntityUpdateHandler.isPathValidForRootDoc(docPath)) {
|
||||
Project.updateOne(
|
||||
Project.update(
|
||||
{ _id: projectId },
|
||||
{ rootDoc_id: newRootDocID },
|
||||
{},
|
||||
@@ -201,7 +201,7 @@ const ProjectEntityUpdateHandler = {
|
||||
|
||||
unsetRootDoc(projectId, callback) {
|
||||
logger.log({ projectId }, 'removing root doc')
|
||||
Project.updateOne(
|
||||
Project.update(
|
||||
{ _id: projectId },
|
||||
{ $unset: { rootDoc_id: true } },
|
||||
{},
|
||||
|
||||
@@ -31,7 +31,7 @@ const ProjectHistoryHandler = {
|
||||
return callback(new Error('invalid history id'))
|
||||
}
|
||||
// use $exists:false to prevent overwriting any existing history id, atomically
|
||||
return Project.updateOne(
|
||||
return Project.update(
|
||||
{ _id: project_id, 'overleaf.history.id': { $exists: false } },
|
||||
{ 'overleaf.history.id': history_id },
|
||||
function(err, result) {
|
||||
@@ -72,7 +72,7 @@ const ProjectHistoryHandler = {
|
||||
if (callback == null) {
|
||||
callback = function(err, result) {}
|
||||
}
|
||||
return Project.updateOne(
|
||||
return Project.update(
|
||||
{ _id: project_id, 'overleaf.history.id': { $exists: true } },
|
||||
{
|
||||
'overleaf.history.display': true,
|
||||
@@ -95,7 +95,7 @@ const ProjectHistoryHandler = {
|
||||
if (callback == null) {
|
||||
callback = function(err, result) {}
|
||||
}
|
||||
return Project.updateOne(
|
||||
return Project.update(
|
||||
{ _id: project_id, 'overleaf.history.upgradedAt': { $exists: true } },
|
||||
{
|
||||
'overleaf.history.display': false,
|
||||
|
||||
@@ -15,7 +15,7 @@ const ProjectOptionsHandler = {
|
||||
}
|
||||
const conditions = { _id: projectId }
|
||||
const update = { compiler }
|
||||
Project.updateOne(conditions, update, {}, callback)
|
||||
Project.update(conditions, update, {}, callback)
|
||||
},
|
||||
|
||||
setImageName(projectId, imageName, callback) {
|
||||
@@ -31,7 +31,7 @@ const ProjectOptionsHandler = {
|
||||
}
|
||||
const conditions = { _id: projectId }
|
||||
const update = { imageName: settings.imageRoot + '/' + imageName }
|
||||
Project.updateOne(conditions, update, {}, callback)
|
||||
Project.update(conditions, update, {}, callback)
|
||||
},
|
||||
|
||||
setSpellCheckLanguage(projectId, languageCode, callback) {
|
||||
@@ -46,7 +46,7 @@ const ProjectOptionsHandler = {
|
||||
}
|
||||
const conditions = { _id: projectId }
|
||||
const update = { spellCheckLanguage: languageCode }
|
||||
Project.updateOne(conditions, update, {}, callback)
|
||||
Project.update(conditions, update, {}, callback)
|
||||
},
|
||||
|
||||
setBrandVariationId(projectId, brandVariationId, callback) {
|
||||
@@ -55,13 +55,13 @@ const ProjectOptionsHandler = {
|
||||
}
|
||||
const conditions = { _id: projectId }
|
||||
const update = { brandVariationId }
|
||||
Project.updateOne(conditions, update, {}, callback)
|
||||
Project.update(conditions, update, {}, callback)
|
||||
},
|
||||
|
||||
unsetBrandVariationId(projectId, callback) {
|
||||
const conditions = { _id: projectId }
|
||||
const update = { $unset: { brandVariationId: 1 } }
|
||||
Project.updateOne(conditions, update, {}, callback)
|
||||
Project.update(conditions, update, {}, callback)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,13 +32,13 @@ module.exports = {
|
||||
lastUpdated: lastUpdatedAt || new Date().getTime(),
|
||||
lastUpdatedBy
|
||||
}
|
||||
return Project.updateOne(conditions, update, {}, callback)
|
||||
return Project.update(conditions, update, {}, callback)
|
||||
},
|
||||
|
||||
markAsOpened(project_id, callback) {
|
||||
const conditions = { _id: project_id }
|
||||
const update = { lastOpened: Date.now() }
|
||||
return Project.updateOne(conditions, update, {}, function(err) {
|
||||
return Project.update(conditions, update, {}, function(err) {
|
||||
if (callback != null) {
|
||||
return callback()
|
||||
}
|
||||
@@ -48,7 +48,7 @@ module.exports = {
|
||||
markAsInactive(project_id, callback) {
|
||||
const conditions = { _id: project_id }
|
||||
const update = { active: false }
|
||||
return Project.updateOne(conditions, update, {}, function(err) {
|
||||
return Project.update(conditions, update, {}, function(err) {
|
||||
if (callback != null) {
|
||||
return callback()
|
||||
}
|
||||
@@ -58,7 +58,7 @@ module.exports = {
|
||||
markAsActive(project_id, callback) {
|
||||
const conditions = { _id: project_id }
|
||||
const update = { active: true }
|
||||
return Project.updateOne(conditions, update, {}, function(err) {
|
||||
return Project.update(conditions, update, {}, function(err) {
|
||||
if (callback != null) {
|
||||
return callback()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user