-
Notifications
You must be signed in to change notification settings - Fork 2
/
db_model.js
49 lines (41 loc) · 1.28 KB
/
db_model.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
var mongoose = require('mongoose');
var C = require('./config.js');
mongoose.connect(C.DB.url);
exports.mongoose = mongoose;
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function callback () {
console.log('Mongoose connected!');
});
var oauthAccessTokenSchema = mongoose.Schema({
access_token: String,
client_id: String,
expires: Date,
user_id: String
},
{ collection : 'OAuthAccessToken' });
exports.OAuthAccessToken = mongoose.model('OAuthAccessToken', oauthAccessTokenSchema);
var oauthRefreshTokenSchema = mongoose.Schema({
refresh_token: String,
client_id: String,
expires: Date,
user_id: String
},
{ collection : 'OAuthRefreshToken' });
exports.OAuthRefreshToken = mongoose.model('OAuthRefreshToken', oauthRefreshTokenSchema);
var oauthClientSchema = mongoose.Schema({
client_id : String,
client_secret : String,
redirect_uri : String,
grant_type: []
},
{ collection : 'OAuthClient' });
exports.OAuthClient = mongoose.model('OAuthClient', oauthClientSchema);
var userSchema = mongoose.Schema({
id : String,
username : String,
service : String,
name: String
},
{ collection : 'SocialUser' });
exports.SocialUser = mongoose.model('SocialUser', userSchema);