On Monday, 4 January 2016 at 17:36:20 UTC, Piotrek wrote:
Thanks! So at least one more soul believing that D can approach
the SQL expressiveness in db domain.
Cheers
Piotrek
Some time ago I had the same idea as yours. IMHO, no D to SQL is
really needed for this, and the same goes for relational
databases. My idea was to initially build a DB as library, using
graph databases as starting point, where the metadata is defined
only one time in the code. The query methods must allow easy
access not only to the data, but also to the relations defined
from object to object. As a starting point you must be able to do
something like this:
// Stores are where the data is saved
auto localStore = FileStore!Endian.littleEndian( "some_file_name"
); // Local file
// load() and save() on objects of type User uses this store.
User.setDefaultStore( localStore );
User user = new User();
user.name = "John";
user.password = sha1( "password" );
// Uses the default store
auto localId = user.save();
// Uses the store specified as argument
auto otherId = user.save( someOtherStore );
// load the object from the default store
User localUser = User.load( localId );
// load the object from the network store
User otherUser = User.load( someOtherStore, otherId );
// Ideally users where the last login is older than one year
using the networkStore
auto oldUsers = User.all( someOtherStore )
.filterUsing!(User.lastLogin, (lastLogin) => lastLogin < ( now
- 1.year ) );
// Select the first user that match userName and hashedPassword
in the default store, with a challenge-response login
auto loginUser = User.all.
.filterUsing!(User.name, (name) => name == userName )
.filterUsing!(User.password, (pass) => hmac( pass, key ) ==
hashedPassword )
.onlyOne();
Gianni Pisetta