我可以获得Mongoose Schema中字段的“maxlength”吗?

时间:2017-08-22 18:20:05

标签: javascript mongoose mongoose-schema

假设我有一个像这样的Mongoose Schema:

import { Schema, Document, model } from 'mongoose';
let MySchema = new Schema({

    name: {
        type: String,
        required: true,
        maxlength: [200, 'Must be {MAXLENGTH} characers or less.']
    }   
}, { collection: 'mystuff' });


const MyModel = model('MyStuff', MySchema);

export { MyModel };

我可以通过maxlength检查name属性MyModel上的内容吗?

0 个答案:

没有答案