UNPKG

modpacksio-common

Version:

Common code for Modpacks.io services

31 lines (27 loc) 707 B
const Schema = require('mongoose').Schema; const id = require('../id'); const category = new Schema({ _id: { type: Number, alias: 'id', default: id.nextId() }, type: String, name: String, description: String, icon: String }); category.methods.toPublic = function () { const obj = this.toObject({ virtuals: true, versionKey: false }); delete obj._id; return obj; }; category.statics.findNoId = async function (categoryId) { const cat = await this.findOne({ _id: categoryId }); if (!cat) return { }; const obj = cat.toObject({ virtuals: false }); delete obj._id; delete obj.type; return obj; }; module.exports = category;