-
Notifications
You must be signed in to change notification settings - Fork 8
/
team.js
55 lines (42 loc) · 907 Bytes
/
team.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
'use strict';
/**
* Model: Team
* - A Slack team that has authorized your Slack Application
*/
// Configure DynamoDb
var AWS = require('aws-sdk');
var dynamoConfig = {
sessionToken: process.env.AWS_SESSION_TOKEN,
region: process.env.AWS_REGION
};
var dynamodbDocClient = new AWS.DynamoDB.DocumentClient(dynamoConfig);
var tableName = 'serverless-slackbot-teams-' + process.env.SERVERLESS_DATA_MODEL_STAGE;
/**
* Team Class
* @constructor
*/
var Team = function() {};
/**
* Show
*/
Team.prototype.show = function(teamId, cb) {
var params = {
TableName : tableName,
Key: {
id: teamId
}
};
return dynamodbDocClient.get(params, cb);
};
/**
* Save
*/
Team.prototype.save = function(team, cb) {
var params = {
TableName : tableName,
Item: team,
ReturnValues: 'ALL_OLD'
};
dynamodbDocClient.put(params, cb);
};
module.exports = Team;