PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Friday the 14th of December, 2018

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[17:04:16] <b10011> Hi, I'm quite new to mongodb and I have this problem with sorting in populate -method. I have populated my query deep and now I want to sort, right, that was easy. But I want to sort with multiple fields. Still successful. But I want to make sure that the order of fields used in sorting is not random.
[17:05:50] <b10011> I know that for .sort() you can give [[fieldname: "<ascending/desceding>"], ...] but for populate options field I can only give { sort: { field1: "ascending", field2: "ascending" } } and nothing guarantees that field1 would be primary field for sorting and field2 secondary field.
[17:11:41] <Derick> no, field1 would definitely be the primary one
[17:11:52] <Derick> but instead of the names "ascending" and "Descirbing", you need to use 1 and -1
[17:12:30] <b10011> Are objects/dictionaries/maps in nodejs ordered?
[17:17:23] <b10011> Damn, those seem to be ordered (Object.keys() always returns them in the same order you defined them).
[17:20:13] <Derick> I don't know node
[17:23:33] <hsiktas> I want to get the average of these floats for each entry in "courses". can I do this with aggregate()?
[17:23:43] <hsiktas> this is how the data looks like: https://usercontent.irccloud-cdn.com/file/jG5YFyVs/image.png
[17:24:11] <Derick> yes, but you really shouldn't use values as keys (the "16")
[17:28:34] <hsiktas> yeah, creating the nested json from a flat csv is one part of the task and I kinda don't know how deal with this structure 🤔
[17:30:17] <hsiktas> in the original data these keys in "course" where course-ids
[17:32:56] <Derick> look at aggregates's $unwind, and $objectToArray
[17:34:48] <hsiktas> thx