Hello inmates,
Recently, I got assigned into the new classified like business project which is fine to develop it from scratch. But I've very less confident on choosing right code architecture(specifically database). Yes, my application stack will be:
Backend:- Node.js (coding in Typescript)
Frontend:- Angular2 (hope u know it is based on Typescript)
But the real challenge begins here:
Database can be anyone of the following 3 services and our application will only know which is the active database service at the run-time (means the database service will be chosen by clients only at deployment process). So I need to satisfy the business logic queries to support all three database services.
These are the preferred services:
1) MySQL 2) MongoDB and 3) Google Cloud Spanner
For this case, many people will suggest ORM is the best solution even I do but there is no library available to hold these three services.
So if you know any lib available please let me know or suggest me with your thoughts.
Matt Strom
Software Engineer, TypeScript ninja
You might struggle to find an ORM for Node that works for all 3 database engines, which employ very different storage paradigms (relational, non-relational, and a hybrid of the two), without writing your own drivers.
Might I suggest instead using a dependency injection container like InversifyJS (inversify.io)? You can then create your abstraction for database access with implementations for each of the DB engines (could be as simple as using the repository pattern) and use Inversify to inject the different drivers at runtime.