You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow specifying client-side tables on models #4791
To use a client-side database, users will need a way to distinguish whether models with the table keyword should generate the repository methods on the server, client or both.
Proposal
To allow this, we could introduce a new database keyword that would accept the values:
server (default)
client
all (mirrored table between server and client).
If the database keyword is omitted when a table keyword is present, the default would be to generate the repository only on the server, preserving the current behavior.
To create client-side tables, users would then do:
class: Greetingtable: greetingdatabase: client # or server, allfields:
message: Stringauthor: Stringtimestamp: DateTimeindexes:
author_index:
type: btree # Only type supported due to SQLite restrictions
The result of the above model would be the dual of what happen today: a model with no repository on the server and a model with repository on the client. If database is set to all, both sides would receive the repository methods.
Restrictions
For tables targeting client or all, model restrictions would be applied considering the most restrictive dialect - which will almost always be SQLite. For example, a model with database set to all would only allow btree indexes, since it is the only type supported by SQLite.
In the future, it is possible to introduce clientOnly and serverOnly keyword for elements such as indexes to allow a more flexible declaration according to each dialect.
Activity
serverpodand into aserverpod_databasepackage #4784