Mercurial > pumpbridge
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:b73191efc65b |
---|---|
1 # Copyright (C) 2014 by Intevation GmbH | |
2 # Author: Mathias Gebbe <mgebbe@intevation.de> | |
3 # | |
4 # This file is Free Software under the Apache License, Version 2.0 | |
5 # (the "License"); and comes with ABSOLUTELY NO WARRANTY! | |
6 # You may not use this file except in compliance with the License. | |
7 # See LICENSE for details. | |
8 | |
9 _ = require("underscore") | |
10 async = require("async") | |
11 DatabankObject = require("databank").DatabankObject | |
12 Usermap = DatabankObject.subClass("usermap") | |
13 | |
14 Usermap.schema = | |
15 pkey: "id" | |
16 fields: [ | |
17 "user_pumpio" | |
18 "user_ESN" | |
19 "oauth_token" | |
20 "extra_token" | |
21 "created" | |
22 ] | |
23 indices: [ | |
24 "user_pumpio" | |
25 "user_ESN" | |
26 ] | |
27 | |
28 Usermap.beforeCreate = (props, callback) -> | |
29 if not props.user_pumpio or not props.user_ESN | |
30 callback new Error("Need 'user_pumpio' and 'user_ESN' in Usermap"), null | |
31 return | |
32 props.id = Usermap.key(props.user_pumpio, props.user_ESN) | |
33 props.created = Date.now() | |
34 callback null, props | |
35 return | |
36 | |
37 Usermap.key = (user_pumpio, user_ESN) -> | |
38 user_pumpio + "_to_" + user_ESN | |
39 | |
40 module.exports = Usermap |