antos-frontend/src/core/db.coffee

20 lines
636 B
CoffeeScript
Raw Normal View History

2018-02-05 19:05:41 +01:00
class DB
constructor: (@table) ->
save: (d, f) ->
_API.handler.dbquery "save", { table: @table, data: d }, f
2018-02-13 04:59:08 +01:00
delete: (c, f) ->
rq = { table: @table }
return _courrier.oserror "Unknown condition for delete command",
(_API.throwe "OS.DB"), c unless c and c inst ""
if isNaN c
rq.cond = c
else
rq.id = c
_API.handler.dbquery "delete", rq, f
2018-02-05 19:05:41 +01:00
get: (id, f) ->
_API.handler.dbquery "get", { table: @table, id: id }, f
find: (cond, f) ->
_API.handler.dbquery "select", { table: @table, cond: cond }, f
self.OS.API.DB = DB