Thread overview
Any project started for libmongoc?
Dec 10, 2019
tirtihen
Dec 10, 2019
JN
Dec 10, 2019
tirithen
Dec 10, 2019
Daniel Kozak
Dec 10, 2019
tirithen
Dec 11, 2019
Andrea Fontana
Dec 12, 2019
Laeeth Isharc
Dec 10, 2019
Adam D. Ruppe
Dec 10, 2019
tirithen
December 10, 2019
Hi, I'm fairly new to the D language, I found it when searching for a fast compiled C-like language with less configuration than C++. I'm mainly a Node.js and Go developer previously so I guess I have been a bit spoiled with a lot of ready made off the shelf third party packages being available.

I want to use it for web development and I'm looking for a good MongoDB driver. I have tried the one used by vibe.d but it lacks a lot of features and I'm now after some way of doing distributed transactions (https://docs.mongodb.com/manual/core/transactions/).

There seem to be a good official C library (http://mongoc.org/) and D is supposed to be good at interfacing against C but it looks like quite a lot of work for a D beginner (around 50 header files).

Is there anyone else that have started on this or similar MongoDB driver already?
December 10, 2019
On Tuesday, 10 December 2019 at 08:53:52 UTC, tirtihen wrote:
> Hi, I'm fairly new to the D language, I found it when searching for a fast compiled C-like language with less configuration than C++. I'm mainly a Node.js and Go developer previously so I guess I have been a bit spoiled with a lot of ready made off the shelf third party packages being available.
>
> [...]

You could give dpp (http://code.dlang.org/packages/dpp) a try, or DStep (https://code.dlang.org/packages/dstep) to generate the C bindings.
December 10, 2019
On Tue, Dec 10, 2019 at 9:55 AM tirtihen via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
>
> Hi, I'm fairly new to the D language, I found it when searchi
> Is there anyone else that have started on this or similar MongoDB
> driver already?

Have you looked at:
https://code.dlang.org/packages/mondo
https://github.com/2night/mondo
December 10, 2019
On Tuesday, 10 December 2019 at 09:01:39 UTC, JN wrote:
> On Tuesday, 10 December 2019 at 08:53:52 UTC, tirtihen wrote:
>> Hi, I'm fairly new to the D language, I found it when searching for a fast compiled C-like language with less configuration than C++. I'm mainly a Node.js and Go developer previously so I guess I have been a bit spoiled with a lot of ready made off the shelf third party packages being available.
>>
>> [...]
>
> You could give dpp (http://code.dlang.org/packages/dpp) a try, or DStep (https://code.dlang.org/packages/dstep) to generate the C bindings.

Thanks, I'll give that a try this evening. :)
December 10, 2019
On Tuesday, 10 December 2019 at 09:29:12 UTC, Daniel Kozak wrote:
> On Tue, Dec 10, 2019 at 9:55 AM tirtihen via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
>>
>> Hi, I'm fairly new to the D language, I found it when searchi
>> Is there anyone else that have started on this or similar MongoDB
>> driver already?
>
> Have you looked at:
> https://code.dlang.org/packages/mondo
> https://github.com/2night/mondo

Yes, I did briefly, I read an article about that team in the blog as well and it seems they are using the code for their online magazine, which is a plus.

But when I search for "transaction" or "session" on GitHub I don't get any hits. It seems like both mondo and vibe.d is fine for plain queries. But for my use case I need the document that is about to be inserted have the next incremental index and also a hash of the previous document as I'm trying to build a blockchain/event store kind of application that is also supposed to run on a MongoDB database setup with replicated instances that all needs to agree on the next index for the next document.

The only way I can think of making this work is with a transaction that reads the previous document and increments and takes the hash from that. Possibly I need to lock the entire for writing collection as well across the replicas. MongoDB version 4+ seems to have a lot of these features, and D seems like a nice language to write the application in. I just need to find a good enough driver somehow. As I'm still new to D the challenge is enough getting the transactions/locking and blockchain/event store right. :D
December 10, 2019
On Tuesday, 10 December 2019 at 08:53:52 UTC, tirtihen wrote:
> Is there anyone else that have started on this or similar MongoDB driver already?

There's this fork https://github.com/symmetryinvestments/mondo/

which used dpp to generate the files. see bsonc.d and mongoc.d in there. not sure if it will build out of the box but it shows the result
December 10, 2019
On Tuesday, 10 December 2019 at 14:35:22 UTC, Adam D. Ruppe wrote:
> On Tuesday, 10 December 2019 at 08:53:52 UTC, tirtihen wrote:
>> Is there anyone else that have started on this or similar MongoDB driver already?
>
> There's this fork https://github.com/symmetryinvestments/mondo/
>
> which used dpp to generate the files. see bsonc.d and mongoc.d in there. not sure if it will build out of the box but it shows the result

Thanks for the help, I'll have a look at that version of mondo as well. I completely missed that it used dpp to generate the files. I'll compare what I need to do with mondo compared to the vibe.d version and see which one is easiest one for my use case.
December 11, 2019
On Tuesday, 10 December 2019 at 14:21:44 UTC, tirithen wrote:
> On Tuesday, 10 December 2019 at 09:29:12 UTC, Daniel Kozak wrote:
>> On Tue, Dec 10, 2019 at 9:55 AM tirtihen via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
>>>
>>> Hi, I'm fairly new to the D language, I found it when searchi
>>> Is there anyone else that have started on this or similar MongoDB
>>> driver already?
>>
>> Have you looked at:
>> https://code.dlang.org/packages/mondo
>> https://github.com/2night/mondo
>
> Yes, I did briefly, I read an article about that team in the blog as well and it seems they are using the code for their online magazine, which is a plus.

We're actually using it for other projects as well!

>
> But when I search for "transaction" or "session" on GitHub I don't get any hits. It seems like both mondo and vibe.d is fine for plain queries. But for my use case I need the document that is about to be inserted have the next incremental index and also a hash of the previous document as I'm trying to build a blockchain/event store kind of application that is also supposed to run on a MongoDB database setup with replicated instances that all needs to agree on the next index for the next document.

Transactions and sessions were not available when I wrap libmongoc. They were added later (in MongoDB, a write operation is atomic on the level of a single document).

I was not aware of symmetry's fork. I wonder why they didn't create a pull request instead!

Andrea


December 12, 2019
On Wednesday, 11 December 2019 at 08:33:02 UTC, Andrea Fontana wrote:
> On Tuesday, 10 December 2019 at 14:21:44 UTC, tirithen wrote:
>> [...]
>
> We're actually using it for other projects as well!
>
>> [...]
>
> Transactions and sessions were not available when I wrap libmongoc. They were added later (in MongoDB, a write operation is atomic on the level of a single document).
>
> I was not aware of symmetry's fork. I wonder why they didn't create a pull request instead!
>
> Andrea

It's only just recently been ready and we had to get dpp working better on Windows first.  I think it's okay now, but not sure.