akf-forum/models/User.js
Akif9748 11965e8de9 ratelimit & crypto & .ejs fix
added ratelimit to post threads and messages.
Added encryption to passwords.
Thread.ejs is fixed
2022-08-10 00:22:12 +03:00

28 lines
No EOL
630 B
JavaScript

const mongoose = require("mongoose")
const schema = new mongoose.Schema({
id: { type: String },
name: String,
avatar: { type: String, default: "/images/guest.png" },
time: { type: Date, default: Date.now },
deleted: { type: Boolean, default: false },
admin: { type: Boolean, default: false }
});
schema.methods.takeId = async function () {
this.id = String(await model.count() || 0);
return this;
}
schema.methods.getLink = function (id = this.id) {
return "/users/" + id;
}
const model = mongoose.model('user', schema);
model.get = id => model.findOne({ id });
module.exports = model;