This is an odd issue I have been seeing. I have a mongoose schema using mongoose-i18n-localize:
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);
In my call I have this:
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);
}
})
});
and I passed in this data:
http://localhost:123/test/1d
{
"active": true,
"name": { "en_US": "test" }
}
I can change active to true and false with no issue. But the name never changes when I make a change. Also I get no error just does not update. Has anyone seen this before or know how to fix this so I can do localization.
via Justin Yanta
No comments:
Post a Comment