Problem to Solve
It would be great if data for a complex type, such as another model, a List, or a Map, would be indexable at the properties level.
Currently these types are stored as a json object in the database:
Proposal
There is a jsonb type in PostgreSQL. jsonb supports indexing, which can be a significant advantage (https://www.postgresql.org/docs/current/datatype-json.html).
It would be great if jsonb was used instead of json, but it probably cannot be changed at this stage (it might be a breaking change for a small percentage of the existing data).
Is it possible to add another ColumnSerializableX column type that would use jsonb in the database?
Or could the used database type for ColumnSerializable be configurable per project (json or jsonb)?
Use Case
The Address class has state and city properties and we would like to index these in the database.
class: Company
table: company
fields:
address: Address # This would be possible if stored as a `jsonb` instead of `json` column
Alternatives
Only ugly ones like extracting state and city properties as separate fields from the Address class.
class: Company
table: company
fields:
address: Address # Stored as a json column
address_state: String # Duplicate of `Address.state`
address_city: String # Duplicate of `Address.city`
Additional context
No response
How experienced are you with this library?
Expert - Experienced and comfortable with using this library in complex projects
Are you interested in working on a PR for this?
Problem to Solve
It would be great if data for a complex type, such as another model, a List, or a Map, would be indexable at the properties level.
Currently these types are stored as a
jsonobject in the database:serverpod/packages/serverpod/lib/src/database/adapters/postgres/database_connection.dart
Line 740 in a638ce4
Proposal
There is a
jsonbtype in PostgreSQL.jsonbsupports indexing, which can be a significant advantage (https://www.postgresql.org/docs/current/datatype-json.html).It would be great if
jsonbwas used instead ofjson, but it probably cannot be changed at this stage (it might be a breaking change for a small percentage of the existing data).Is it possible to add another
ColumnSerializableXcolumn type that would usejsonbin the database?Or could the used database type for
ColumnSerializablebe configurable per project (jsonorjsonb)?Use Case
The
Addressclass hasstateandcityproperties and we would like to index these in the database.Alternatives
Only ugly ones like extracting
stateandcityproperties as separate fields from theAddressclass.Additional context
No response
How experienced are you with this library?
Expert - Experienced and comfortable with using this library in complex projects
Are you interested in working on a PR for this?