mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
5861231548
- need to run migration 1 before using this for this to work - added acceptence test so new documents updated should be upserted, not return 404
43 lines
1.2 KiB
CoffeeScript
43 lines
1.2 KiB
CoffeeScript
request = require("request").defaults(jar: false)
|
|
{db, ObjectId} = require("../../../../app/js/mongojs")
|
|
|
|
module.exports = DocstoreClient =
|
|
|
|
createDoc: (project_id, doc_id, lines, callback = (error) ->) ->
|
|
db.docs.save({_id: doc_id, project_id:project_id, lines: lines, rev:1}, callback)
|
|
|
|
createDeletedDoc: (project_id, doc_id, lines, callback = (error) ->) ->
|
|
db.docs.insert {
|
|
_id: doc_id
|
|
project_id: project_id
|
|
lines: lines
|
|
deleted: true
|
|
}, callback
|
|
|
|
getDoc: (project_id, doc_id, qs, callback = (error, res, body) ->) ->
|
|
request.get {
|
|
url: "http://localhost:3016/project/#{project_id}/doc/#{doc_id}"
|
|
json: true
|
|
qs:qs
|
|
}, callback
|
|
|
|
getAllDocs: (project_id, callback = (error, res, body) ->) ->
|
|
request.get {
|
|
url: "http://localhost:3016/project/#{project_id}/doc"
|
|
json: true
|
|
}, callback
|
|
|
|
updateDoc: (project_id, doc_id, lines, callback = (error, res, body) ->) ->
|
|
request.post {
|
|
url: "http://localhost:3016/project/#{project_id}/doc/#{doc_id}"
|
|
json:
|
|
lines: lines
|
|
}, callback
|
|
|
|
deleteDoc: (project_id, doc_id, callback = (error, res, body) ->) ->
|
|
request.del {
|
|
url: "http://localhost:3016/project/#{project_id}/doc/#{doc_id}"
|
|
}, callback
|
|
|
|
|
|
|