PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Friday the 20th of September, 2019

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[13:54:51] <temhaa> hello mongo users
[13:55:00] <temhaa> I am trying to create a query for my document
[13:55:03] <temhaa> I need your help
[13:55:15] <temhaa> I have a document somethingl ike that: http://dpaste.com/0XZQNS0
[13:56:32] <temhaa> I need to take reference type=cities object and if per city in cities list is exists object which related type=city-name I need to add their code
[13:56:42] <temhaa> I wanna create a response something like that
[13:56:43] <temhaa> cities
[13:56:48] <temhaa> http://dpaste.com/2YMBHTC
[13:57:29] <temhaa> would you like to help me
[14:59:06] <dbe> Hey! I'm new to Mongo, and I created this query through mongodb's cli which utilizes the "map" function on cursors, e.g. "db.users.find().map(function(user) { user.devices = db.devices.find({"user": user.email}); return user; })". Now, my question is, is this *one* query to mongo, or is the map evaluated on the *cli site* resulting in very many queries?
[14:59:18] <dbe> cli side*
[15:06:59] <markizano> ok, since "view" is such a common search term, I am not finding what I am looking on Google >_>
[15:07:08] <markizano> How doth one list all views in a schema in MongoDB ??
[15:07:22] <markizano> or at least iterate over all the collections and determine which ones are views?
[15:25:14] <GothAlice> dbe: That's client-side. find() returns a cursor. Iteration of that cursor consumes records sent by the server to the client "over the wire". map is one such method of iterating the results, iteratively invoking a callback function to process each record.
[15:27:13] <GothAlice> Which means that's a rather unfortunate setup. If there are few enough records, you can pull them all in (consume down to an array of actual records), collect the e-mail addresses, and issue a {"user": {"$in": [… array of email addresses …]}} then consume *those* results into a mapping. So when finally utilizing the array of users for presentation, the data can be pulled out of that mapping. "Cached", if you will, but critically
[15:27:13] <GothAlice> importantly, only issuing two queries total.
[15:27:30] <GothAlice> Not a geometric number of queries. ;^P
[15:29:37] <GothAlice> The only actual part of a "query" in that line, BTW, is the actual .find() calls. Between those parenthesis is the query. The first one uses the default empty mapping ({}) blank query, meaning no filtering criteria, gimme everything.