Next, we are going to update our message model. We are going to save the translated text, along with the language code to our message. This way, we can retrieve the translation for a given message and not hit the Translate API every time. Update servermodelsmessage.ts as shown here:
// SNIPP SNIPP
translations: {
type: Schema.Types.Mixed
}
// SNIPP SNIPP
Do note that this variable stores an object and not an array. The object will be built as follows:
// SNIPP SNIPP
{
'fr': 'Bonjour le monde!',
'en': 'Hello World!'
}
// SNIPP SNIPP
So, querying this variable will be easy given the language code.