1
votes

Let's imagine document with localisations like this:

{  
    "Id":"product/1",  
    "CategoryId":"categories/1",  
    "Translations":[  
        { "Lang": "en", "Title:"en title"},  
        { "Lang": "hr", "Title:"hr title"}
    ]
} 

and I want to get from Raven projected/flattened/filtered results that looks like this, if I query for index CategoryId:"categories/1" AND Lang:"en":

{  
    "Id":"product/1",
    "CategoryId":"categories/1",  
    "Lang":"en",  
    "Title":"en title"
}

so basically, document contains localized strings in array, and I want to get only one language. Filtering on client is not a problem, but how to do it on raven server, with Transformer?

Or, can you suggest some other document structure for storing localised content? Currently, I have separate documents Product and ProductTranslation (for every language), but would like to have it all under one doc (looks more OO:/)

1

1 Answers

1
votes

If the only difference between products is the translations, I would go with a different model. The product document would have categoryId, price and all the rest of the product info.

Assuming a product is saved under products/1, you can then save additional documents under IDs like products/1/en, products/1/es etc and store the translated strings there. You can then use ResultTransformers to inject the translated strings into the end result of queries.