Install: @travetto/model-sql
npm install @travetto/model-sql
# or
yarn add @travetto/model-sql
The current SQL client support stands at:
- MySQL Model Service - MySQL 8.6+
- PostgreSQL Model Service - Postgres 14+
- SQLite Model Service - (bettersqlite 8.0+)
-
SQL Server
- Currently unsupported -
Oracle
- Currently unsupported
Note: Wider client support will roll out as usage increases.
The SQL Model Service works quite a bit different than the average Object Relationship Mapping in that it makes assertions about how data is stored in the database. The primary goal of the SQL support is not to handle every scenario that a relational database can provide, but to integrate with the Data Modeling Support structure, while leverage relational datastores to the best of their abilities.
The primary difference is around unique identifiers, and how parent/child relationships are managed. In a normal database primary keys could be composite values between various fields. For example a unique identifier could be a combination of date
+ orderNumber
+ customerNumber
. This is perfectly normal in a relational model, but SQL Model Service assumes unique identifiers (UUID) as 32-character hexadecimal values. In addition to these unique values, the parent's identifier is required in all children values. This allows for some fairly optimized querying, updates, and deletions on changes.
What this translates to, is that the framework here dictates the final schema, and doesn't support adapting to existing relational data stores. In greenfield projects, this is not an issue, but will most likely preclude its use in adapting to existing relational data sets.