-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.coffee
More file actions
28 lines (22 loc) · 757 Bytes
/
server.coffee
File metadata and controls
28 lines (22 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
exports.onInstall = !->
exports.client_task = (id, data) !->
# Validate
if !data.name
log "[task] #{user()} id:", id, "no name provided:", JSON.stringify(data)
if !data.description
log "[task] #{user()} id:", id, "no description provided:", JSON.stringify(data)
# Assign id if new
if !id
data.created = new Date()/1000
data.createdBy = App.userId()
id = Db.shared.incr 'taskMax'
else
data.edited = new Date() / 1000
data.editedBy = App.userId()
log "[task] #{user()} id:", id, "data:", JSON.stringify(data)
Db.shared.set 'tasks', id, data
exports.client_delete = (id) !->
log "[delete] #{user()} id:", id
Db.shared.remove 'tasks', id
user = (userId) !->
App.userName(userId)+"("+App.userId(userId)+")"