猫鼬v5.9.8-将架构数组转换为架构图?

I'm wondering how I can convert roles to a Map? Usually I do myDocument.roles.id("myRoleID") would I do myDocument.roles.get("myRoleID")?

const { Schema } = require("mongoose")

module.exports = new Schema({
    roles: [new Schema({
        _id: {
            type: String,
            required: true
        },
        permission_level: {
            type: Number,
            default: 0,
            enum: [0, 1, 2, 3]
        },
        auto_role: {
            type: Boolean,
            default: false
        },
        joinable: {
            type: Boolean,
            default: false
        }
    })],
})
评论