mgebbe@0: # Copyright (C) 2014 by Intevation GmbH mgebbe@0: # Author: Mathias Gebbe mgebbe@0: # mgebbe@3: # This file is Free Software under the Apache License, Version 2.0; mgebbe@3: # and comes with NO WARRANTY! mgebbe@3: # See the documentation coming with pumpbridge for details. mgebbe@0: mgebbe@0: _ = require("underscore") mgebbe@0: async = require("async") mgebbe@0: DatabankObject = require("databank").DatabankObject mgebbe@0: ToESN = DatabankObject.subClass("toESN") mgebbe@0: mgebbe@0: ToESN.schema = mgebbe@0: pkey: "uid" mgebbe@0: fields: [ mgebbe@0: "sourceUser" mgebbe@0: "sourcePost" mgebbe@0: "targetUser" mgebbe@0: "targetPost" mgebbe@0: "recipientUser" mgebbe@0: "created" mgebbe@0: "updated" mgebbe@0: ] mgebbe@0: indices: [ mgebbe@22: "uid" mgebbe@0: "sourceUser" mgebbe@0: "sourcePost" mgebbe@0: "targetUser" mgebbe@0: "targetPost" mgebbe@0: ] mgebbe@0: mgebbe@0: ToESN.beforeCreate = (props, callback) -> mgebbe@0: if not props.sourcePost or not props.sourceUser mgebbe@0: callback new Error("Need 'sourceUser' and 'sourceUser'"), null mgebbe@0: return mgebbe@0: props.created = Date.now() mgebbe@0: props.updated = Date.now() mgebbe@0: callback null, props mgebbe@0: return mgebbe@0: mgebbe@0: ToESN::beforeSave = (callback) -> mgebbe@0: props = this mgebbe@0: if not props.sourcePost or not props.sourceUser mgebbe@0: callback new Error("Need 'sourceUser' and 'sourceUser'"), null mgebbe@0: return mgebbe@0: props.updated = Date.now() mgebbe@0: callback null mgebbe@0: return mgebbe@0: mgebbe@0: module.exports = ToESN