MongoDB/DB <-> D

Daniel Kozak via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Oct 27 12:14:57 PDT 2016


Dne 27.10.2016 v 20:54 Jot via Digitalmars-d-learn napsal(a):

> Using Vibe.D here;
>
> How can one work with the DB's abstractly without incurring duplicity. 
> I'd like to be able to create one struct and use that, either in D or 
> the DB. I'd prefer to create a struct in D and interact through that 
> struct with the database abstracted away.
>
> struct Person
> {
>     string name;
>     ...
> }
>
> Person Joes = Person.Query!name("^Joe.*")
>
> Or whatever is an appropriate example.
>
>
>
> What Iwant to avoid is having to duplicate the database structures in 
> their native language(json for mongodb).
>
> Or, maybe there is a D struct to json convertor?
>
What are you describe here is called ORM (Object relational mapping) in 
this case it is much more like SRM (Struct relational mapping). AFAIK 
there is no ORM for mongodb, and it does not make much sense because 
mongo is not relational database. But maybe one of these libraries could 
be useful http://code.dlang.org/packages/asdf
http://code.dlang.org/packages/jsonizer


More information about the Digitalmars-d-learn mailing list