UNPKG

rauth

Version:

Authentication and Authorization library via JWT

44 lines 1.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const ConnectionStore_1 = require("../store/ConnectionStore"); class MongooseEngine { constructor({ model } = {}) { if (!model) { throw new Error('Require Model'); } this.model = model; } async deleteById(sessionId) { await this.model.deleteOne({ sessionId }); return true; } async deleteByIds(sessionIds) { throw new Error('Method not implemented.'); } async deleteByUserId(userId) { await this.model.deleteMany({ userId }).lean(); return true; } async update(register, sets) { return this.model.findOneAndUpdate({ sessionId: register.sessionId, }, { $set: sets, }, { new: true, }).lean(); } async findById(sessionId) { return this.model.findOne({ sessionId }).lean(); } async findByUserId(userId) { return this.model.find({ userId }).lean(); } async create(sessionRegister) { const doc = await this.model.create(sessionRegister); return doc.toJSON(); } } exports.MongooseEngine = MongooseEngine; ConnectionStore_1.ConnectionStore.add('Mongoose', MongooseEngine); //# sourceMappingURL=MongooseEngine.js.map