1

使用以下方案,文档在大约 1 分钟后被删除。目的是为每个文档提供createdAtand字段。updatedAt

let userSchema = new mongoose.Schema({
    name: {
        type: String,
        required: true,
        minlength: 2,
        maxlength: 50,
    },
    email: {
        type: String,
        required: true,
        minlength: 5,
        maxlength: 255,
        unique: true,
    },
    password: {
        type: String,
        required: true,
        minlength: 5,
        maxlength: 1024,
    },
}, {
    timestamps: true
});
4

0 回答 0