1
I’m working with Nodejs, Mongodb and Mongoose where I’m creating a system of access permissions that work with infinite sublevels. Permissions have the same Schema:
//app/models/PermissaoModel.js
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
var PermissaoSchema = new Schema({
alias: { type: String, unique: true },
nome: { type: String, required: true },
descricao: { type: String, default: '' },
padrao: { type: Boolean, default: true },
itens: [PermissaoSchema] // <- aqui está meu problema...
});
module.exports = mongoose.model('Permissao', PermissaoSchema);
//o resultado seria algo como:
permissao:{
alias,
nome,
descricao,
padrao,
itens:[permissao, permissao, permissao, permissao, ...]
}
But in trying to create this sublevel structure, my code is making a mistake by saying I can’t use it as a reference...
How can I create an infinite sublevel structure to work with these permissions?