Saturday, 28 September 2013

General Database/Data Access Layer API

General Database/Data Access Layer API

I'm currently building a web application with a RESTfull architecture.
Currently, I have 3 major collections: Users, Posts, and Comments with the
following relationships:
User --(hasMany)--> Post --(hasMany)--> Comment
And, the expected web-API's (GET /Users, GET /Users/Id, GET /Post/Id, POST
/Post/Id,...)
Currently, I'm using MongoDB for data persistence, which works perfectly
as I can setup 3 major Collections: Users, Posts, Comments and use either
Object _id references or actual document embedding to model the
relationships.
However, my employer is skeptical of MongoDB, and thus I'd like to leave
the door open in the event we switch to something more conventional
(mySQL, MS-SQL,...)
As such, I'm looking to loosely couple my database, and so I need to come
up with a data access layer api that I can tie to noSQL or SQL - based
databases.
Bonus: additionally, I need to connect to existing database
infrastructure, and would like to encapsulate these requests under the
same data-access umbrella as well.
Something like:
// mongo-inspired
db.find(<string bucket>).where(<string
attribute>).is(<string/number/object value)
// SQL-like
db.select(<[string] attribute1>).from(<string bucket>).where(...) ...
Is there any general database/data access API that I can emulate?
Thanks.

No comments:

Post a Comment