How to save multilingual data using Node.js + Mongoose + MongoDB?

Problem

I want to save multilingual data in my database. In Django, I was using django-transmeta and I could save and access the multilingual data easily.

In Mongoose, how I should save the data, or which modules should I use to to this?

For example, I want to save the names of an item in 3 languages:

In db, should it be:

{
  name : {
        en : 'Car',
        tr : 'Araba',
        es : 'Coche'
  }
}
Problem courtesy of: Burak

Solution

Yes you are right...

That is one way of doing it:

{
  _id
  name : {
        en : 'Car',
        tr : 'Araba',
        es : 'Coche'
  }
}

Another is:

{
   YourId:'1'
   locale: 'en',   
   name: 'Car'
}
{
   YourId:'1'
   locale: 'tr',   
   name: 'Araba'
}
{
   YourId:'1'
   locale: 'es',   
   name: 'Coche'
}

And in the 2nd example, its good to index 'YourId' & 'locale'

Solution courtesy of: Amol M Kulkarni

Discussion

There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.