📌  相关文章
📜  什么是 mongo db 中的模型模式文档 - Go 编程语言 - Go 编程语言代码示例

📅  最后修改于: 2022-03-11 14:45:00.212000             🧑  作者: Mango

代码示例1
var personSchema = new Schema({
    name: { type: String, default: 'anonymous' },
    age: { type: Number, min: 18, index: true },
    bio: { type: String, match: /[a-zA-Z ]/ },
    date: { type: Date, default: Date.now },
});

var personModel = mongoose.model('Person', personSchema);
var comment1 = new personModel({
    name: 'Witkor',
    age: '29',
    bio: 'Description',
});

comment1.save(function (err, comment) {
    if (err) console.log(err);
    else console.log('fallowing comment was saved:', comment);
});