[19:18:43] <UberWeasel> Hey folks, I'm in a bit of a pickle. I know NOTHING about mongo. But, I need to do some work for a client that uses it. I'm using db.getCollection("users").find({}, { "_id" : "$_id", "profile.age": "$profile.age" } ); to get all the records in a collection. profile.age has values of NaN in a few rows, which the client has reason to keep, so I just need it fixed when I run the above. Is there a way to do so in MongoDB?
[19:42:02] <SDr|hu> UberWeasel, how do you mean fixed?
[19:42:30] <UberWeasel> Sorry, don't really mean fixed - bad choice of words. Need it set to an int instead of NaN.
[19:48:37] <SDr|hu> UberWeasel, more generally, https://docs.mongodb.com/manual/reference/method/db.collection.update/
[19:49:11] <UberWeasel> Won't that update the data in the MongoDB collection? I only want to change the value on query - they want to keep the NaN in the database, but it's borking our conduit.
[19:51:40] <SDr|hu> UberWeasel, I see. What is being borked specifically? your client crashes for accessing NaN results?
[19:51:53] <SDr|hu> (what are you using for client-side access? language / ORM)
[19:52:02] <UberWeasel> SDr|hu: Yeah, it's a bug in the FDW we are using on PostgreSQL.
[19:52:23] <UberWeasel> SDr|hu: Until fixed, I need a workaround.
[19:56:10] <SDr|hu> UberWeasel, as far as I can tell, this is only possible with aggregations: https://docs.mongodb.com/manual/reference/operator/aggregation/ifNull/
[19:56:28] <SDr|hu> which might not be as elegant a workaround as hoped for
[19:56:47] <UberWeasel> SDr|hu: Aggregation would allow me to create a view though, which I can get to through the FDW.