Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add comments for HTTP method used to access controller

  • Loading branch information...
commit 4524ae85dde1b949c25d239de6cdd173dab69674 1 parent ae2fe33
Raphaël Bleuse authored
Showing with 8 additions and 0 deletions.
  1. +8 −0 app/controllers/data_controller.coffee
View
8 app/controllers/data_controller.coffee
@@ -8,6 +8,7 @@ connection = new cradle.Connection
db = connection.database("cozy")
+# GET /data/exist/:id
action 'exist', ->
db.head params.id, (err, res, status) ->
if status is 200
@@ -15,6 +16,7 @@ action 'exist', ->
else if status is 404
send {"exist": false}
+# GET /data/:id
action 'find', ->
db.get params.id, (err, doc) ->
if err
@@ -23,6 +25,8 @@ action 'find', ->
delete doc._rev # CouchDB specific, user don't need it
send doc
+# POST /data
+# POST /data/:id
action 'create', ->
if params.id
db.get params.id, (err, doc) -> # this GET needed because of cache
@@ -43,6 +47,7 @@ action 'create', ->
else
send {"_id": res.id}, 201
+# PUT /data/:id
action 'update', ->
# this version don't take care of conflict (erase DB with the sent value)
db.get params.id, (err, doc) ->
@@ -57,6 +62,7 @@ action 'update', ->
else
send 404
+# PUT /data/upsert/:id
action 'upsert', ->
# this version don't take care of conflict (erase DB with the sent value)
db.get params.id, (err, doc) ->
@@ -70,6 +76,7 @@ action 'upsert', ->
else
send {"_id": res.id}, 201
+# DELETE /data/:id
action 'delete', ->
# this version don't take care of conflict (erase DB with the sent value)
db.get params.id, (err, doc) ->
@@ -84,6 +91,7 @@ action 'delete', ->
else
send 404
+# PUT /data/merge/:id
action 'merge', ->
# this version don't take care of conflict (erase DB with the sent value)
db.get params.id, (err, doc) ->
Please sign in to comment.
Something went wrong with that request. Please try again.