diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/commenttoesn.coffee	Thu Jun 05 10:35:15 2014 +0200
@@ -0,0 +1,49 @@
+# Copyright (C) 2014 by Intevation GmbH
+# Author: Mathias Gebbe <mgebbe@intevation.de>
+#
+# This file is Free Software under the Apache License, Version 2.0
+# (the "License"); and comes with ABSOLUTELY NO WARRANTY!
+# You may not use this file except in compliance with the License.
+# See LICENSE for details.
+
+_ = require("underscore")
+async = require("async")
+DatabankObject = require("databank").DatabankObject
+CommentToESN = DatabankObject.subClass("CommentToESN")
+
+CommentToESN.schema =
+  pkey: "uid"
+  fields: [
+    "ESNPost"
+    "pumpComment"
+    "created"
+    "updated"
+  ]
+  indices: [
+    "ESNPost"
+    "pumpComment"
+  ]
+
+CommentToESN.beforeCreate = (props, callback) ->
+  if not props.ESNPost or not props.pumpComment
+    callback new Error("Need 'ESNPost' and 'pumpComment'"), null
+    return
+  props.uid = CommentToESN.key(props.pumpComment, props.ESNPost)
+  props.created = Date.now()
+  props.updated = Date.now()
+  callback null, props
+  return
+
+CommentToESN::beforeSave = (callback) ->
+  props = this
+  if not props.ESNPost or not props.pumpComment
+    callback new Error("Need 'ESNPost' and 'pumpComment'"), null
+    return
+  props.updated = Date.now()
+  callback null
+  return
+
+CommentToESN.key = (pumpComment, ESNPost) ->
+  pumpComment + "_to_" + ESNPost
+
+module.exports = CommentToESN
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)