기존 앱에 배지가 "1234567"인 사용자를 만들 수있는 스키마가 있습니다. maxlength 유효성 검사의 유효성 검사 오류 b/c를받을 것으로 예상됩니다.몽구스 배열 개체 maxlength 유효성 검사가 작동하지 않습니다.
내 스키마에 어떤 문제가 있습니까?
module.exports = function(db) {
var mongoose = require('mongoose');
var appSchema = mongoose.Schema({
name: {
type: String,
required: true,
unique: true,
},
settings: mongoose.Schema.Types.Mixed,
user: [{
badge: {
type: String,
minlength: 5,
maxlength: 5
}
}]
});
// Export the schema for the app to use
return db.model('apps', appSchema);
}
나는 앱 문서의 배열에 새 사용자 레코드를 추가
apps.findByIdAndUpdate(req.params.id, {$push: {user: req.body.user}}, {runValidators: true},callback());
를 사용하는 것을 시도하고있다.
여전히 작동하지 않는 것 같습니다. 이것은 기존의 앱에 사용자 레코드를 삽입하는 방법입니다.'apps.findByIdAndUpdate (req.params.id, {$ push : {user : req.body.user}}, {runValidators : true}, 콜백()); – Catfish