mirror of
https://github.com/ENSL/ensl_gathers.git
synced 2024-12-11 13:21:40 +00:00
18 lines
432 B
JavaScript
18 lines
432 B
JavaScript
"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);
|