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: Usermap = DatabankObject.subClass("usermap") mgebbe@0: mgebbe@0: Usermap.schema = mgebbe@0: pkey: "id" mgebbe@0: fields: [ mgebbe@0: "user_pumpio" mgebbe@0: "user_ESN" mgebbe@0: "oauth_token" mgebbe@0: "extra_token" mgebbe@0: "created" mgebbe@0: ] mgebbe@0: indices: [ mgebbe@0: "user_pumpio" mgebbe@0: "user_ESN" mgebbe@0: ] mgebbe@0: mgebbe@0: Usermap.beforeCreate = (props, callback) -> mgebbe@0: if not props.user_pumpio or not props.user_ESN mgebbe@0: callback new Error("Need 'user_pumpio' and 'user_ESN' in Usermap"), null mgebbe@0: return mgebbe@0: props.id = Usermap.key(props.user_pumpio, props.user_ESN) mgebbe@0: props.created = Date.now() mgebbe@0: callback null, props mgebbe@0: return mgebbe@0: mgebbe@0: Usermap.key = (user_pumpio, user_ESN) -> mgebbe@0: user_pumpio + "_to_" + user_ESN mgebbe@0: mgebbe@0: module.exports = Usermap