PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Tuesday the 14th of May, 2019

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[21:24:32] <GothAlice> Ankhers: I know not of the functions you speak. "With" is actually a reserved word (control flow statement) in Python.
[21:26:05] <GothAlice> If you are referring to the shell special syntax, a la "use <dbname>", that's the REPL equivalent of: db = db.connection[<dbname>] — pop back up to the connection from the current DB, fetch the target DB, reassign state.
[21:26:48] <GothAlice> (They're quite explicitly not functions.)
[21:27:07] <Ankhers> GothAlice: I was looking at the Ruby driver as a reference. I have since looked at multiple languages and there seems to be no uniform syntax for Ruby's `use' function. It does what the shell syntax does, it selects which database to run the given query against.
[21:28:25] <GothAlice> https://github.com/mongodb/mongo-ruby-driver/blob/22b4942ecd3fc410ee57d1e5095d7d92c398f387/lib/mongo/client.rb#L475-L492
[21:29:02] <GothAlice> Found using GitHub search: https://github.com/mongodb/mongo-ruby-driver/search?q=%22def+use%22&unscoped_q=%22def+with%22
[21:29:12] <GothAlice> Pretend I also manually updated the last parameter. ;P
[21:30:23] <GothAlice> Various "with" implementations appear to be mutation factories: https://github.com/mongodb/mongo-ruby-driver/blob/7ebedaa654f90c68c9bf9d84121ceba340164b61/lib/mongo/collection.rb#L148-L158 — just hand back a new object with the same settings as ours, merged with those passed in.
[21:31:23] <GothAlice> What my APIs call "adapt". E.g. id = Document.id.adapt(…)
[21:33:07] <Ankhers> Yes. I just thought there would be a specificication for that function, but like I said, I have since found that various drivers have different ways of selecting which database to run a query against.
[21:33:29] <GothAlice> Ankhers: Switching from one "active database" to another is not something most languages need to bother with in the first place.
[21:33:40] <GothAlice> For example, the Python driver does not have the concept of a singular active database.
[21:34:00] <GothAlice> (That's a mongo REPL concern.)
[21:34:44] <GothAlice> You never "switch". You just access the target database directly when needed.
[21:37:03] <GothAlice> Heh. I'm getting the same sense of impedance mismatch as the Django folks had when implementing "multiple database connection support". They updated > 1 million lines of code (enough that the Trac instance would crash attempting to view the diff…) to add a connection parameter and logic to literally every function and method. In my own framework, it as 15 lines, predominantly one for loop. 👍
[21:37:22] <GothAlice> s/it as/it was/
[21:37:58] <Ankhers> I thought the python version could do `client[database]' to choose the database?
[21:38:52] <GothAlice> Yup. But that's not a "switch_db" invocation of any kind. There is no active DB. client[database] is an expression evaluating to ("returning") the target database.
[21:39:14] <Ankhers> Oh okay. That makes sense.
[21:39:34] <GothAlice> a=client['foo']; b=client['bar']; c=client['bar'] — simultaneously manipulate three databases at the same time.
[21:39:50] <GothAlice> For various definitions of "at the same time". ;^P
[21:40:52] <Ankhers> I may need to rethink my current approach.
[21:41:11] <GothAlice> Hehe. Also reminds me of the difficulty convincing students that in async code, there is no thread. None. At all. ;^P