comparison src/toESN.coffee @ 0:b73191efc65b

Initial import of pumpbridge (bloody bloody alpha)
author Mathias Gebbe <mgebbe@intevation.de>
date Thu, 05 Jun 2014 10:35:15 +0200
parents
children 98a070c98982
comparison
equal deleted inserted replaced
-1:000000000000 0:b73191efc65b
1 # Copyright (C) 2014 by Intevation GmbH
2 # Author: Mathias Gebbe <mgebbe@intevation.de>
3 #
4 # This file is Free Software under the Apache License, Version 2.0
5 # (the "License"); and comes with ABSOLUTELY NO WARRANTY!
6 # You may not use this file except in compliance with the License.
7 # See LICENSE for details.
8
9 _ = require("underscore")
10 async = require("async")
11 DatabankObject = require("databank").DatabankObject
12 ToESN = DatabankObject.subClass("toESN")
13
14 ToESN.schema =
15 pkey: "uid"
16 fields: [
17 "sourceUser"
18 "sourcePost"
19 "targetUser"
20 "targetPost"
21 "recipientUser"
22 "created"
23 "updated"
24 ]
25 indices: [
26 "sourceUser"
27 "sourcePost"
28 "targetUser"
29 "targetPost"
30 ]
31
32 ToESN.beforeCreate = (props, callback) ->
33 if not props.sourcePost or not props.sourceUser
34 callback new Error("Need 'sourceUser' and 'sourceUser'"), null
35 return
36 props.created = Date.now()
37 props.updated = Date.now()
38 callback null, props
39 return
40
41 ToESN::beforeSave = (callback) ->
42 props = this
43 if not props.sourcePost or not props.sourceUser
44 callback new Error("Need 'sourceUser' and 'sourceUser'"), null
45 return
46 props.updated = Date.now()
47 callback null
48 return
49
50 module.exports = ToESN
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)