[09:41:01] <ocx32> hello all, i am trying to create a collection of visitors, it looks like vvisitorGeoRegion,counter whenever i get a new visitor i need to increate the counter if it is not 0 and create a new document with GeoRegion and counter=1 how can i do that ?
[09:43:06] <ocx32> is there a way to create new if none or increate by 1 if exist?
[22:56:39] <lenswipe> I want to cross reference that with another collection ID. Is there a way to do that in a mongo query?
[22:56:48] <lenswipe> I can't use $lookup because it's mongo 3.0.x
[22:58:07] <lenswipe> i basically want to do the equivalent of a left join between two collections
[23:44:11] <GothAlice> $lookup is the implementation of that feature request.
[23:45:24] <lenswipe> GothAlice, but $lookup isn't available until Mongo 3.2 :)
[23:45:30] <lenswipe> So I guess that means I'm stuck doing it on the client then?
[23:47:55] <GothAlice> Which is a fairly explicitly bad idea. Geometric query growth is not a way to scale well. You may wish to restructure your data a bit; keep the bits you need from the $lookup with the reference. E.g. when displaying forum threads, I need the user's name for display, so I store: reply={"author": {"_id": ObjectId('…'), "name": "GothAlice"}, "content": "…", …}
[23:49:12] <GothAlice> You can query by ID easily ({author._id: …}) and when retrieving, you get the "foreign values" you need. Trade-off: updating them when the "cached" value changes, which you may want, or you may have reasons to explicitly not want (i.e. versioning, audit logs, etc.)
[23:50:32] <GothAlice> Other useful/example case: invoices. Where the line item's presentation must not change, even if the item ordered does at a time after that order was made. Storing the name with the reference at that time becomes a business need.