mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
24 lines
No EOL
842 B
CoffeeScript
24 lines
No EOL
842 B
CoffeeScript
{db, ObjectId} = require "./mongojs"
|
|
|
|
module.exports = MongoManager =
|
|
findProject: (project_id, callback = (error, project) ->) ->
|
|
db.projects.find _id: ObjectId(project_id.toString()), {}, (error, projects = []) ->
|
|
callback error, projects[0]
|
|
|
|
findDoc: (doc_id, callback = (error, doc) ->) ->
|
|
db.docs.find _id: ObjectId(doc_id.toString()), {}, (error, docs = []) ->
|
|
callback error, docs[0]
|
|
|
|
updateDoc: (project_id, docPath, lines, callback = (error) ->) ->
|
|
update =
|
|
$set: {}
|
|
$inc: {}
|
|
update.$set["#{docPath}.lines"] = lines
|
|
update.$inc["#{docPath}.rev"] = 1
|
|
|
|
db.projects.update _id: ObjectId(project_id), update, callback
|
|
|
|
insertDoc: (project_id, doc_id, attributes, callback = (error) ->) ->
|
|
attributes._id = ObjectId(doc_id)
|
|
attributes.project_id = ObjectId(project_id)
|
|
db.docs.insert attributes, callback |