[13:47:31] <synthmeat> this makes no sense. `for await (let doc of cursor) { ... }` works fine until i put in the loop body `await cursor.hasNext()`, which makes the loop error out on last doc with "Cursor is closed" at the loop body line :/
[13:48:07] <synthmeat> does .hasNext have side-effects?
[14:00:36] <synthmeat> ugh. `if (!hasNext) break;` looks really dirty. what's the point of iterator otherwise!? :(
[14:11:57] <GothAlice> synthmeat: That seems less MongoDB’s fault than using a “programming language” in air quotes.
[14:13:54] <synthmeat> honestly? it's probably node.js driver's fault, it's kinda shoddy. can't quite put my finger on it though, but it just feels it degraded over the years. maybe they just don't want node devs using mongo anymore :/
[14:14:29] <synthmeat> GothAlice: pure node can still run circles around pure python any time of day ^_^
[14:15:55] <synthmeat> no, v8's a monster, truly. it's insane, i keep getting surprised left and right how good it is.
[14:16:44] <GothAlice> synthmeat: Talk to me again when you build a C10K (tested: ab -c 10000 -n 1000000) HTTP/1.1 conforment HTTP server (supporting both chunked responses *and* requests) in 171 opcodes without using external C modules.
[14:16:51] <GothAlice> Oh, on hardware 8 years old.
[14:18:30] <synthmeat> i probably won't. but StephenLynx might have already done it (wouldn't be surprised)
[14:18:55] <GothAlice> I could almost limit the challenge to “just manage to test 10,000 concurrent connections at all”, which is its own legitimate challenge. But that’d be too Google’able.
[14:19:33] <GothAlice> That example “ab” line won’t actually work. It’ll die after 2.5 seconds when it runs out of TCP ports to allocate. ;)
[14:20:53] <pagios> hi all, is it possible to increment a counter in a document and push an object to an array all in 1 command in mongo or should they be 2 seperate commands?
[14:21:29] <GothAlice> pagios: You can… stack as many alteration operations as you need into a single update…
[14:21:30] <synthmeat> i do have ~5k (data heavy) ws connections now up and running (load balanced over 6 nodes). they're hardly loaded at all tho. i would be surprised if 50k connections would tip it over.
[14:22:56] <GothAlice> synthmeat: “I would be surprised” = a complete guess, without any form of backing. https://gist.github.com/amcgregor/707936#file-terminal-2-apachebench-L65-L69 ← average 14MB of RAM utilization after processing 100,000 requests at a concurrency of 10,000. :mic drop:
[14:25:02] <synthmeat> yeah, of course it's speculation. i remember it going up to ~20k, so ~3k per node, without any trouble.
[14:26:11] <synthmeat> in any case, if i had 10k per node, i'd be able to hire GothAlice to solve it, so it's moot :D
[14:26:16] <pagios> Or do i chain some .updateMany (..).updateMany(...) ?
[14:28:10] <GothAlice> I don’t know what this is, but it isn’t a MongoDB query, let alone anything close to valid JavaScript: https://paste.webcore.io/?updateMany(%0A%09%09%7Bsubscribers:+subscriber},%0A%09%09%7B+%24pull:%7B+subscribers:+subscriber}+},%0A%09%09%7B_id:+channel,+[],+%7B+%24addToSet:+%7Bsubscribers:+subscriber},+%7Bnew:+true}%0A%09)%3B
[14:30:14] <GothAlice> Notice the very first example. It performs two update operations on matched documents. It both sets a status value, and increments a quantity. Your exact question. Found by: http://lmgtfy.com/?q=mongodb+update+many clicking the first MongoDB Manual link, then clicking on “Update with an Update Operator Expressions Document” linked therein.
[14:32:42] <GothAlice> synthmeat: I run CMS sites receiving thousands of visitors per hour. These run on nodes with 256MB of RAM and shared CPU utilization costing 0.2€/day. Efficient doesn’t mean expensive or large.
[14:33:21] <GothAlice> In fact, efficient literally means the opposite. You can use smaller, and less expensive infrastructure to service the same userbase.
[15:12:23] <pagios> any idea what is wrong with my pymong? mycol.update_one({'_id':x['_id'],{'$addToSet': {'pub: ch}},upsert = True) ? nothing is being added i am trying to create an array and push an element to it
[15:50:00] <pagios> GothAlice, mycol.update({'_id':x['_id']},{'$addToSet': {'c: c, '$inc': { x['available'] : -1 }}) <--- what is wrong here?
[15:50:37] <GothAlice> Invalid syntax. Instantly I recognize the mismatched quotes; the error is within two bytes of the start of the quoted string.
[15:51:20] <GothAlice> Additionally, you are absolutely mangling the definition of what an “operation” is. Please read up on how to issue updates. Find a tutorial. Really.
[15:54:00] <GothAlice> {‘$addToSet’: …} and {‘$inc’: …} are two *different operations*. You are ‘combining’ them in a way that is not close to supported. “Mixing concerns.”
[15:54:16] <pagios> so i cannot have 2 operations inside 1 updatE?
[15:54:39] <GothAlice> You absolutely can. But you haven’t written two operations. You’ve written one. That is inexplicably containing a second, that will never be interpreted as an operation.
[15:55:17] <GothAlice> Have a really good look at what you’ve written.
[15:55:37] <GothAlice> All sorts of nesting that has no business being there.
[15:56:05] <GothAlice> If your update starts with {{ ← you’ve already done it wrong.
[15:57:48] <GothAlice> Additionally, why the heck are you referring to the field in the second half by its value?
[15:58:09] <GothAlice> x[‘available’] == a number that is the value of the “available” field within the document “x”. That is *not* the *name* of a field to update.
[15:58:52] <GothAlice> … I do not comprehend how or why you could end up thinking that.
[15:59:24] <GothAlice> mapping[key] ← “dereference” the given key from the mapping, retrieving its associated value. It’s that way in virtually every programming language in the world.
[16:00:06] <GothAlice> (Thus… just drop mapping[ and ] from around key. And you have the name of the key. Already.)
[16:21:03] <ocx32> hi, i have a collection with multiple documents, each document has an id and an array of subdocuments , i want to select the document where i have inside it a subdocument, remove the subdocument and increase a value on document how can i do that?
[16:24:57] <GothAlice> ocx32: updateOne, filter to the document matching your sub-document criteria, $pull, $inc.
[16:26:14] <GothAlice> pagios / ocx32: Kinda weird to be connected twice.