|
@@ -56,6 +56,8 @@ module.exports = ProjectEntityMongoUpdateHandler = self =
|
|
|
conditions = _id:project._id
|
|
conditions = _id:project._id
|
|
|
inc = {}
|
|
inc = {}
|
|
|
inc["#{path.mongo}.rev"] = 1
|
|
inc["#{path.mongo}.rev"] = 1
|
|
|
|
|
+ # we need to increment the project version number for any structure change
|
|
|
|
|
+ inc['version'] = 1
|
|
|
set = {}
|
|
set = {}
|
|
|
set["#{path.mongo}.created"] = new Date()
|
|
set["#{path.mongo}.created"] = new Date()
|
|
|
update =
|
|
update =
|
|
@@ -144,9 +146,11 @@ module.exports = ProjectEntityMongoUpdateHandler = self =
|
|
|
return callback(error) if error?
|
|
return callback(error) if error?
|
|
|
endPath = path.join(path.dirname(entPath.fileSystem), newName)
|
|
endPath = path.join(path.dirname(entPath.fileSystem), newName)
|
|
|
conditions = {_id:project_id}
|
|
conditions = {_id:project_id}
|
|
|
- update = "$set":{}
|
|
|
|
|
|
|
+ update = "$set":{}, "$inc":{}
|
|
|
namePath = entPath.mongo+".name"
|
|
namePath = entPath.mongo+".name"
|
|
|
update["$set"][namePath] = newName
|
|
update["$set"][namePath] = newName
|
|
|
|
|
+ # we need to increment the project version number for any structure change
|
|
|
|
|
+ update["$inc"]["version"] = 1
|
|
|
Project.findOneAndUpdate conditions, update, { "new": true}, (error, newProject) ->
|
|
Project.findOneAndUpdate conditions, update, { "new": true}, (error, newProject) ->
|
|
|
return callback(error) if error?
|
|
return callback(error) if error?
|
|
|
ProjectEntityHandler.getAllEntitiesFromProject newProject, (error, newDocs, newFiles) =>
|
|
ProjectEntityHandler.getAllEntitiesFromProject newProject, (error, newDocs, newFiles) =>
|
|
@@ -174,9 +178,11 @@ module.exports = ProjectEntityMongoUpdateHandler = self =
|
|
|
update = {"$unset":{}}
|
|
update = {"$unset":{}}
|
|
|
update["$unset"][path] = 1
|
|
update["$unset"][path] = 1
|
|
|
model.update conditions, update, {}, (err)->
|
|
model.update conditions, update, {}, (err)->
|
|
|
- pullUpdate = {"$pull":{}}
|
|
|
|
|
|
|
+ pullUpdate = {"$pull":{}, "$inc":{}}
|
|
|
nonArrayPath = path.slice(0, path.lastIndexOf("."))
|
|
nonArrayPath = path.slice(0, path.lastIndexOf("."))
|
|
|
pullUpdate["$pull"][nonArrayPath] = null
|
|
pullUpdate["$pull"][nonArrayPath] = null
|
|
|
|
|
+ # we need to increment the project version number for any structure change
|
|
|
|
|
+ pullUpdate["$inc"]["version"] = 1
|
|
|
model.findOneAndUpdate conditions, pullUpdate, {"new": true}, callback
|
|
model.findOneAndUpdate conditions, pullUpdate, {"new": true}, callback
|
|
|
|
|
|
|
|
_countElements: (project)->
|
|
_countElements: (project)->
|
|
@@ -245,8 +251,10 @@ module.exports = ProjectEntityMongoUpdateHandler = self =
|
|
|
element._id = require('mongoose').Types.ObjectId(id)
|
|
element._id = require('mongoose').Types.ObjectId(id)
|
|
|
conditions = _id:project._id
|
|
conditions = _id:project._id
|
|
|
mongopath = "#{path.mongo}.#{type}"
|
|
mongopath = "#{path.mongo}.#{type}"
|
|
|
- update = "$push":{}
|
|
|
|
|
|
|
+ update = "$push":{}, "$inc":{}
|
|
|
update["$push"][mongopath] = element
|
|
update["$push"][mongopath] = element
|
|
|
|
|
+ # we need to increment the project version number for any structure change
|
|
|
|
|
+ update["$inc"]["version"] = 1# increment project version number
|
|
|
logger.log project_id: project._id, element_id: element._id, fileType: type, folder_id: folder_id, mongopath:mongopath, "adding element to project"
|
|
logger.log project_id: project._id, element_id: element._id, fileType: type, folder_id: folder_id, mongopath:mongopath, "adding element to project"
|
|
|
Project.findOneAndUpdate conditions, update, {"new": true}, (err, project)->
|
|
Project.findOneAndUpdate conditions, update, {"new": true}, (err, project)->
|
|
|
if err?
|
|
if err?
|