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 }
|
2018-02-16 18:38:14 +01:00
|
|
|
return ( _courrier.oserror "Unknown condition for delete command",
|
|
|
|
(_API.throwe "OS.DB"), c ) unless c and c isnt ""
|
2018-02-13 04:59:08 +01:00
|
|
|
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
|