mirror of
https://github.com/ENSL/ensl_gathers.git
synced 2024-12-02 00:52:54 +00:00
19 lines
432 B
JavaScript
19 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);
|