Skip to content

Instantly share code, notes, and snippets.

@hyzhak
Last active August 29, 2015 14:08
Show Gist options
  • Select an option

  • Save hyzhak/fb6175e6a0072128b0c1 to your computer and use it in GitHub Desktop.

Select an option

Save hyzhak/fb6175e6a0072128b0c1 to your computer and use it in GitHub Desktop.
i18n of MongoDB (Mongoose) - normalization vs de-normalization
// de-normalized
{
"_id": <ObjectId1>,
"name": {
"en": "Eugene",
"uk": "Євген"
}
}
//or normalized
//1st data collection
{
"_id": <ObjectId1>,
"name": "1"//reference to id of 2nd collection
}
//2nd i18n collection
[
{
"_id": <ObjectId2>,
"id": "1", //reference to name of 1nd collection
"value": "Eugene"
},
{
"_id": <ObjectId2>,
"id": "1", //reference to name of 1nd collection
"value": "Євген"
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment