These are chat archives for Automattic/mongoose

13th
Jul 2017
Sabeer Sulaiman
@sabeersulaiman
Jul 13 2017 07:12
Any help : StackExchange
Dennis Belany
@azarus
Jul 13 2017 13:20
They going to have different names, descriptions and attributes based on the language. So they are different products completely with a very few data being the same. Am i right? Probably would make sense to have them as different products. And to make it to be a less hassle offer an option to duplicate the product and change the properties according to the language?
@sabeersulaiman
Also if theres a search people would search for the product name on their own language
You can also move the descriptions or common properties on a different collection and just reference them.
Sabeer Sulaiman
@sabeersulaiman
Jul 13 2017 13:23
Yes, but the issue I faced was now updating the common elements in a product becomes a lot of work(in the case of one document for each language). But this seems the best way I suppose
@azarus the other approach is also implemented but there could be multiple variants, so that lead to the confusion
I actually have implemented both aproaches explained in the question
Still not optimistic about both :(
Dennis Belany
@azarus
Jul 13 2017 14:46
Well i wouldn't worry about usability (less hassle) when it comes to the database
When i did my multi lang webshop i simply gave them an option to duplicate a product so they can translate it
If you have 20 languages, then you have to do the changes 20 times anyways.
It can't be any more easier than that. I'd make it so the less buttons they press the "less hassle" it is :)
Sabeer Sulaiman
@sabeersulaiman
Jul 13 2017 14:48
Yeah going with the multi document approach, I am worried about updation times rather than usability though. Well I guess everything comes with a price
And also there is a doubt our regional langauge is not yet supported by mongodb (for text index), so defaulting such languages to english. Will they still be searchable ?
Dennis Belany
@azarus
Jul 13 2017 16:22
yea, though not soo fast
but it depends on the number of records you need to search in
We have like 2 million records storing large texts in documents, and we perform 10-20 searches on this collection every second and i wouldn't say we have issues with the database yet. And thats not indexed
but thats just test data yet
Parth Shah
@parths3an
Jul 13 2017 16:56
Hello everyone, I am new to this platform and I don't if this a right place for this conversation. But Can someone direct me how do I go about using mongoose with typescript and connection to mongodb? and also let me know if there any other platform where this question would be appropriate if not here. Thank you.
Julio Borja Barra
@juboba
Jul 13 2017 19:22
Hey, I would like to find all the categories where a property, which is an array is either empty or contains certain element. How can I do this?
I was trying this first, but I can't use $or this way. Any ideas?
  Category.find({
    title : {
      $elemMatch : { name },
    },
    restricted: {
      $or: [
        { $exists: true, $eq: [] },
        { $exists: false },
      ],
    },
  }, options)
Julio Borja Barra
@juboba
Jul 13 2017 19:57
I did it with:
$and: [
{ title : {
      $elemMatch : { name },
    },
},
{
      $or: [
        { restricted: [] },
        { restricted: { $exists: false } },
        { restricted: Types.ObjectId(userId) },
      ],
    }
]
is it possible to search for documents according to a property of a related document?
I mean, if posts have categories, can I search for posts where categories.name: /something/?
Adel
@AdelMahjoub
Jul 13 2017 23:13
@juboba take a look at populate Query conditions and other options section, maybe it is what you need