[02:57:06] <RyansWorld> hello everyone I have a question about mongodb with mongoose. Is there a way to prevent duplicate records? Here is what im faced with. I have a CSV sheet that I have to grab from a website and update to my database. There is one field in the schema that is unique and should only ever have one. Is there a way to prevent an insert if the field is already in the DB? or is there a way to scrub the DB after insert and
[17:02:33] <dougs> hi there, got a strange problem with indexes here. suddenly our mongodb queries with backward sorting started all returning no results. i could fix it only by creating a new index with descending order on the same field of the previous index. tried to search but could not find anything. what could that be?
[17:03:04] <dougs> "suddenly" may be some change i'm not aware, but anyway i don't know where to look...
[18:29:28] <hotpot33> Well, is sorting on a embedded object field as easy as {$sort: { 'x.y': 1 }} ?
[19:01:25] <alfredocambera> Hello fellas, I'm trying to filter documents (example data https://pastebin.com/gNjmGsHj) from a collection where 'gd' should contain an array, and that array may be named: "SD" or "SOMETHING". I've tried using: '{"gd": {"$in": ["SA", "SOMETHING"]} }' to filter but it seems like I'm doing something wrong
[19:09:28] <alfredocambera> I'm very new to mongo. Could anybody take a look at the example data? Any hint on how to extract the information would be highly appreciated
[20:44:54] <synaptech> alfredocambera: it looks like you're trying to get documents that contain an element 'gd' that contains either an element named 'SD' or 'SOMETHING', but in your query you're looking for docs that have the value SA or SOMETHING in the gd element
[20:46:34] <synaptech> I think you'd want something like {"gd.SA": { $exists: true }}
[20:47:45] <synaptech> note that that doesn't check if the element is an array, just that the element exists
[20:49:03] <synaptech> do the same for gd.SOMETHING and wrap both expressions in an $or: [{<exp1>}, {<exp2>}]
[21:45:41] <alfredocambera> synaptech: thanks a lot!