comparison src/commenttoesn.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 CommentToESN = DatabankObject.subClass("CommentToESN")
13
14 CommentToESN.schema =
15 pkey: "uid"
16 fields: [
17 "ESNPost"
18 "pumpComment"
19 "created"
20 "updated"
21 ]
22 indices: [
23 "ESNPost"
24 "pumpComment"
25 ]
26
27 CommentToESN.beforeCreate = (props, callback) ->
28 if not props.ESNPost or not props.pumpComment
29 callback new Error("Need 'ESNPost' and 'pumpComment'"), null
30 return
31 props.uid = CommentToESN.key(props.pumpComment, props.ESNPost)
32 props.created = Date.now()
33 props.updated = Date.now()
34 callback null, props
35 return
36
37 CommentToESN::beforeSave = (callback) ->
38 props = this
39 if not props.ESNPost or not props.pumpComment
40 callback new Error("Need 'ESNPost' and 'pumpComment'"), null
41 return
42 props.updated = Date.now()
43 callback null
44 return
45
46 CommentToESN.key = (pumpComment, ESNPost) ->
47 pumpComment + "_to_" + ESNPost
48
49 module.exports = CommentToESN
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)