Design MongoDb collection to support multiple versions and multiple languages

I have a set of related json files for version 1. The identical set exists in 5 other languages. Every 6 months a new version of the files is released. How should these files be stored so that if the user selects a version and a particular language , the data is displayed.

example:

version 1_english:
highlevel.json
lowlevel.json

version 1_korean:
highlevel.json
lowlevel.json

version 2_english:
highlevel_json
lowlevel_json

Hi @Supriya_Bansal,

I suggest to read the following:

Building with Patterns: The Document Versioning Pattern | MongoDB Blog

Combination of the two can give you an idea .

In high level your documents could look something like:

{
"_id" : ... ,
"revision" : ...,
"modifiedDate" : "...",
"en" : [ { "greeting" : "hello"}, ...],
"fr" : [ {"greeting" : "bonjour"}, ...],
...
}

Another option is to consider a collection per language or database per language.

Best regards
Pavel

1 Like

Thank you @Pavel_Duchovny for sharing these links.
I looked into the articles and have a follow-up question about the version.
The UI needs to display all the available versions in a drop-down list. If you select a specific version the data should be displayed for that version.
Is it advisable to have one database per version as well?

Hi @Supriya_Bansal,

I won’t do versioning based on databases. I would index the user and versions fields within a collection and query a new query each time a user switches the version.

Or query all versions into separate parameters and populate ui on switch.

Thanks
Pavel

1 Like

This is really helpful @Pavel_Duchovny. Thank you!

Hi.
what if documents look something like this ?

{
    "_id" : ... ,
    "revision" : ...,
    "modifiedDate" : "...",
    greeting:[{
        "lang":"en",
        "valu":"hello"},{
        "lang":"fr",
        "valu":"bonjour"
    }]
}

Hi @farzam_raoufi ,

The document looks like a possible candidate for version pattern. What is your specific question?

Thanks
Pavel

I’m just new in MongoDB and think it can be good idea to build multiple languages document.
i will study more about version pattern.
Thank you!