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