brick / orm

Object-relational mapper for PHP 8 - Currently in development 🚧
10 stars 1 forks source link

Support for storing whole entities as JSON documents #4

Open BenMorel opened 5 years ago

BenMorel commented 5 years ago

Several databases now have first-class support for JSON, allowing to store whole entities as JSON documents, like in a NoSQL database.

We do have support for individual JSON columns, but it would be interesting to add support to store a whole entity (all properties) as a single JSON column.

The table would look like:

id   INT PRIMARY KEY
data JSON

It should be possible to mix entities mapped in a typical object-to-relational way, and entities mapped to JSON, in the same application, with support from this library.

BenMorel commented 5 years ago

Note: instead of just choosing between the relational or document model for a given entity, it could also be interesting to have the option to save a single entity to both a set of relational tables, and a denormalized JSON table.

The database could contain both models simultaneously: a relational write model, and a denormalized read model.

The ORM could handle transparent persistence to both models.