-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsessionModel.js
43 lines (34 loc) · 987 Bytes
/
sessionModel.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
var dal = require('agg-mongo-dal');
module.exports = function(collection) {
var model = {};
collection = collection || 'sessions';
// console.log('Session model is being used with collection: %s', collection);
model.create = function (session, callback) {
console.log('Creating a session in collection: %s', collection);
console.log('test');
dal.create(collection, session, callback);
};
model.readByToken = function (token, callback) {
var restrictions = {
eq: {
token: token
}
}
dal.list(collection, restrictions, callback);
};
model.deleteTokensByIds = function (ids, callback) {
dal.removeByIds(collection, ids, callback);
};
model.update = function(guid, fields, callback) {
dal.update(collection, guid, fields, callback);
};
model.findExpiredSessions = function(createdTime, callback) {
var restrictions = {
lt: {
createdTimestamp: createdTime
}
};
dal.list(collection, restrictions, callback);
};
return model;
}