Permalink
Browse files

wip: tracks:update

  • Loading branch information...
1 parent 636065e commit b0fc629cbc5f44daffe25544f58ec249938f1083 @comotion committed Nov 21, 2012
Showing with 7 additions and 8 deletions.
  1. +6 −1 web/hangover.lua
  2. +1 −7 web/lib/tracks.lua
View
@@ -144,9 +144,14 @@ function put_db(web,...)
local input = web.POST
u.out(input)
if not input then
+ web.status = "501 someone fucked up"
return json.encode{{result=nil, error="nothing to put"}}
end
- return tracks:update(id, input)
+ if not tracks:update(id, input) then
+ web.status = "501 fubar"
+ return json.encode{{result=nil, error="failed to put"}}
+ end
+ return json.encode(tracks:get(id))
end
-- DELETE /db/:id:
-- Remove
View
@@ -168,13 +168,7 @@ function tracks:get(pkey)
end
function tracks:update(pkey, cols)
- p = tracks:get(pkey)
- -- merge teh data
- for k,v in pairs(cols) do
- p[k] = v
- end
- cols.updated = os.time()
- return tracks:put(pkey, p)
+ return tracks:put(pkey, cols)
end
-- return result with only fields

0 comments on commit b0fc629

Please sign in to comment.