Mercurial > pumpbridge
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/toESN.coffee Thu Jun 05 10:35:15 2014 +0200 @@ -0,0 +1,50 @@ +# 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 +ToESN = DatabankObject.subClass("toESN") + +ToESN.schema = + pkey: "uid" + fields: [ + "sourceUser" + "sourcePost" + "targetUser" + "targetPost" + "recipientUser" + "created" + "updated" + ] + indices: [ + "sourceUser" + "sourcePost" + "targetUser" + "targetPost" + ] + +ToESN.beforeCreate = (props, callback) -> + if not props.sourcePost or not props.sourceUser + callback new Error("Need 'sourceUser' and 'sourceUser'"), null + return + props.created = Date.now() + props.updated = Date.now() + callback null, props + return + +ToESN::beforeSave = (callback) -> + props = this + if not props.sourcePost or not props.sourceUser + callback new Error("Need 'sourceUser' and 'sourceUser'"), null + return + props.updated = Date.now() + callback null + return + +module.exports = ToESN