[英]how to define a trigger in a mongoose schema
在mongoose模型級別是否有任何類型的觸發器,當成員集合的數量達到100時,它提供設置open field = false的能力?
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var listSchema = new Schema({
name: {
type: String,
required: true,
trim: true
},
desc: {
type: String
},
open: {
type: Boolean,
default: true
},
members: [{
userid: {
type: Schema.Types.ObjectId, ref: 'User'
},
prId: {
type: Schema.Types.ObjectId, ref: 'PR'
},
checkedIn: {
type: Boolean
}
}]
});
module.exports = mongoose.model('List', listSchema);
mongo中沒有觸發器。 很難說為什么你想要在收藏達到一定限度時更改文件,可能有限制收藏是你真正想要的?
new Schema({..}, { capped: { size: 1024, max: 100 } });
size是最大集合大小(以字節為單位),max是可以在集合中插入的最大文檔數。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.