lua-mongo icon indicating copy to clipboard operation
lua-mongo copied to clipboard

Session support

Open gil-opplane opened this issue 4 years ago • 4 comments

Hey,

I've been looking at the code you implemented and, first of all, thanks for all the work. Now, I have a task at hand where I need to use a transaction to create multiple collections and commit or abort depending on the jobs' success. This should be available on the latest mongo version (4.4), so I went searching for the class in your code where the notion of transaction or session was implemented. Unfortunately, I didn't find them.

Am I missing something? Or, if not, are you planning on implementing these notions soon?

Here's the documentation I've been looking at:

Thanks in advance.

gil-opplane avatar Nov 18 '20 14:11 gil-opplane

First, I'll answer your questions directly:

  1. No, there's no direct support for client sessions in lua-mongo;
  2. No, there are no plans to implement this API along with other rarely used features.

Now, on a positive note, Mongo C Driver like all other MongoDB drivers/clients is just a wrapper around MongoDB's wire protocol. The protocol of MongoDB is essentially BSON objects going back and forth. A driver provides some basic functionality that helps the user to avoid handling basic I/O, constructing commands and parsing responses themselves. Please note that different drivers have a different level of abstraction dealing with this task. For example, the PHP driver handles most high level abstractions like instances, objects, sessions, etc. itself without relying on the underlying C driver (mongo-c-driver). There are drivers that imple

There's a generic client:command() in lua-mongo that you can use to implement nearly all other commands and queries. In particular, take a look here for the underlying mechanics of Server Sessions: https://docs.mongodb.com/manual/reference/server-sessions/

neoxic avatar Nov 19 '20 01:11 neoxic

Hi,

I'll look into the :command() method. I'm already using it in other parts with other tasks, I was just looking whether there was an easier way to do this through a direct method. Thanks nonetheless.

gil-opplane avatar Nov 19 '20 10:11 gil-opplane

I'm in favour to leave this issue open to see if there's demand for this feature and it's worth implementing it in the long run.

neoxic avatar Nov 20 '20 06:11 neoxic

Hi,

Sure, thanks. I'll see what I can do on my side, but I'll keep a close look on this.

gil-opplane avatar Nov 20 '20 09:11 gil-opplane