1
1
Fork 0
mirror of https://github.com/Akif9748/akf-forum.git synced 2025-03-14 10:27:21 +03:00
akf-forum/models/cache.js

13 lines
351 B
JavaScript
Raw Normal View History

2022-08-31 14:44:28 +03:00
const UserModel = require("./User");
const UserCache = [];
module.exports.getAuthor = async function () {
const id = this.authorID || this.author?.id;
let user = UserCache.find(user => user?.id == id)
if (!user) {
user = await UserModel.findOne({ id })
UserCache.push(user)
}
this.author = user;
return this;
}