PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Tuesday the 2nd of October, 2018

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[14:08:21] <ropt> Hello, how can I get the current operation ID that I started, in order to kill it?
[14:10:01] <Derick> ropt: https://docs.mongodb.com/manual/reference/method/db.currentOp/
[14:10:19] <Derick> with https://docs.mongodb.com/manual/reference/method/db.killOp/
[14:22:39] <ropt> @Derrick: thanks, I wonder, though, how I'm going to get my current operation ID, in the case where many operations are running simultaneously? Can I add a unique, known by me, identifier as metadata to the operation when I initialize it?
[14:23:42] <Derick> I think you can add a comment to a command at least
[14:23:47] <Derick> not sure if you can do that for queries too
[14:25:32] <Derick> I'm wrong, you can: https://docs.mongodb.com/manual/reference/operator/meta/comment/
[14:29:14] <ropt> @Derrick, thanks I'll look into it. Do you think this is the right approach to be able to identify and kill my operation?
[14:57:09] <cpama> guys, i'm just new to mongo and i'm wondering what the proper way is to maintain a list that's used in other documents. so imagine a web form, where you can fill out your address. if i want to display a list of states in the USA... is it wrong to create a separate collection in mongo to hold these values?
[14:57:50] <cpama> and then that leads to my next question which is... let's say i have 50 documents in my "customers" collection that has the value "New York" in the state field.
[14:58:31] <cpama> if later on, we want to change the "states" collection to read "NY" instead of "New York"... what's the proper way to make sure these changes get cascaded to the existing documents in the customer collection?
[14:59:23] <cpama> right now, i'm reading through of the docs found here:https://docs.mongodb.com/manual/tutorial/model-referenced-one-to-many-relationships-between-documents/
[15:00:16] <cpama> so i think i should be saving each state as a separate item with an ID in the state collection.
[15:00:25] <cpama> and then just "Reference" by ID. is this the correct way?
[23:19:34] <MonicleLewinsky> Hi guys, I'm new to mongo and I'm having trouble with a query. I want to get the distinct values for a key and the count of each value.
[23:20:08] <MonicleLewinsky> So for example if my collection had fruit in it, I'd want the output of the query to be like "apple: 2, orange: 6, banana: 1"
[23:21:06] <MonicleLewinsky> Or if my collection was car models, the output would be "ford: 5, chevy: 8, toyota: 1"
[23:41:42] <synthmeat> MonicleLewinsky: db.fruit_purchases.aggregate( { $group: { _id: '$fruit_type' } }, { $group: { _id: 1, fruit_count: { $sum: 1 } } }) and probably some projection in pipeline to massage it to whatever exact format you need
[23:42:05] <MonicleLewinsky> synthmeat: Awesome, thanks. I literally just found the aggregate function
[23:42:35] <synthmeat> MonicleLewinsky: it's important functionality. arguably most important. read about it.
[23:42:51] <MonicleLewinsky> Will do. This is day for me on mongo
[23:44:04] <synthmeat> 4.0 is great, you'll love it. install MongoDB Compass to play with it. it has pretty good aggregate pipeline editor, with preview, export etc.