Mongoose / Node.JS中的本地化值不会更新

这是我所看到的一个奇怪的问题。 我有一个使用mongoose-i18n-localize的mongoose模式:

var mongoose = require('mongoose'); var mongooseI18n = require('mongoose-i18n-localize'); var Schema = mongoose.Schema; var TestSchema = new Schema({ id: String, active: {type: Boolean, default: false}, name: {type: String, required: true, i18n: true} }); TestSchema.plugin(mongooseI18n, { locales: ['en_US'] }); module.exports = mongoose.model('Test', TestSchema); 

在我的电话中,我有这样的:

 app.put('/test/:id', function(req, res) { var query = {'id': req.params.id); var test = req.body; Test.findOneAndUpdate(query, test, function(err,p) { if (err) { handleError(res, err.message, "Failed to get information"); console.log(err); } else { res.json(p); } }) }); 

我传递了这个数据:

 http://localhost:123/test/1d { "active": true, "name": { "en_US": "test" } } 

我可以改变主动为真和假,没有问题。 但是,当我做出改变时,这个名字永远不会改变。 我也没有错误,只是不更新​​。 有没有人看过这个之前,或知道如何解决这个问题,所以我可以做本地化。

你应该以这种方式发送身体,它为我工作:

 { "active": true, "name.en_US": "test" } 
Interesting Posts