Add required
property to schema definitions
#173
Labels
thinking about how to do it
Not forgotten, but need to sleep on it
required
property to schema definitions
#173
Is your feature request related to a problem? Please describe.
I've been using schemas for typed queries on my store. The tooling is excellent, but I was surprised to find "not null" checks are required for all fields. I understand this is a design decision to keep TinyBase flexible. However, I expected a
required
property to be supported on schemas to assert values are not null when adding entries.Describe the solution you'd like
I'd like to see a
required
property on schema definitions to enforce defined fields. I'd expect this to be a boolean value alongsidetype
anddefault
:store.setTablesSchema({ pets: { species: { type: 'string', + required: true, }, legs: {type: 'number', default: 4}, sold: {type: 'boolean', default: false}, }, });
Describe alternatives you've considered
I've asserted that all values are not-null when adding or updating entries. This gets quite noisy when using TypeScript.
Additional context
I recall hearing
required
was supported when listening to your interview on the Local-first podcast (great stuff by the way!). However, I haven't been able to find this in the documentation or by attempting to addrequired
in my code.The text was updated successfully, but these errors were encountered: