UNPKG

crafta

Version:

Lightweight, modular Node.js framework

33 lines (30 loc) 631 B
const mongoose = require('mongoose'); const roleSchema = new mongoose.Schema({ name: { type: String, required: true, unique: true }, permissions: [{ resource: String, actions: [{ type: String, enum: ['create', 'read', 'update', 'delete', 'manage'] }] }], description: String, isSystem: { type: Boolean, default: false }, createdAt: { type: Date, default: Date.now }, updatedAt: Date }); roleSchema.pre('save', function(next) { this.updatedAt = new Date(); next(); }); module.exports = mongoose.model('Role', roleSchema);