Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

251
Views
Localized Values are not updating in Mongoose/Node.JS

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.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You should send the body using dot notation instead of brackets. It worked for me in this way:

{
  "active": true,
  "name.en_US": "test"
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!