0
我有一个猫鼬的架构,我刚添加的领域“imagens”的原始模式。猫鼬版本错误和不匹配的文件发现ID
添加的字段是:
imagens:[{title:{type: String},savedAs:{type: String},file:{type: String}, thumb:{type: String}}],
现在,当我试图填补“imagens”字段和更新集合,我得到了一个错误。 如果我摆脱掉了线“item.imagens = IMGS”的错误消失。
我在做什么错?有没有解决这个问题?
//错误
{"data":{"message":"No matching document found for id \"5909caeed32a453b537f7966\"",
"name":"VersionError"}, "status":500,
"config":{"method":"POST","transformRequest":[null],"transformResponse":[null],"jsonpCallbackParam":"callback",
"url":"/uploads",
"data":{"file":{"$ngfBlobUrl":
"blob:http://localhost/9c4b0449-1ddd-4e39-ab44-f2e9a21bfd82","$ngfWidth":450,"$ngfHeight":321,
"upload":{},"progress":100},"pacID":"5909caeed32a453b537f7966"},"_isDigested":true,
"_chunkSize":null,"headers":{"Accept":"application/json, text/plain, */*"},"_deferred":{"promise":"..."},"cached":false},"statusText":"Internal Server Error"}
//在我的路由器
Cliente.findById(pac_id, function (err, item) {
if (err) {
return res.status(500).send(err);
} else {
item.imagens=imgs
}
item.save(function (err, data) {
if (err) {
return res.status(500).send(err)
}
if (answers.results.length){
answers.message='Some files was not uploaded'
} else {
answers.message='Files were uploaded'
}
res.send(answers)
})
})
//模型
const mongoose=require('mongoose');
const clientesSchema = new mongoose.Schema({
id: {type: Number, unique:true},
nome: {type: String, unique:true},
ativo: {type: Boolean},
...
...
foto: { data: Buffer, contentType: String },
imagens:[{title:{type: String},savedAs:{type: String},file:{type: String}, thumb:{type: String}}],
created_at:{type:Date,default:Date.now},
altered_at:{type:Date,default:Date.now}
});
module.exports = mongoose.model('Cliente', clientesSchema,'clientes');
谢谢杰里米,但我尝试过了,问题仍然存在。 It's奇怪,因为如果我把只有一个图像到我的“imagens”阵列,出现问题doesn't。如果我把两个或两个以上的图像物品进入现场数组,我有一个显示 –
谢谢你的问题,这是它。我犯了一个错误。 –