ensl_gathers/db/models/session.js

19 lines
432 B
JavaScript
Raw Normal View History

2015-08-18 09:56:35 +00:00
"use strict";
var mongoose = require("mongoose");
var Schema = mongoose.Schema;
var crypto = require('crypto');
var keyGenerator = () => {
return crypto.randomBytes(20).toString('hex');
};
var sessionSchema = new Schema({
userId: { type: Number, required: true },
key: { type: String, required: true, default: keyGenerator }
});
sessionSchema.index({ userId: 1 });
module.exports = mongoose.model("Session", sessionSchema);