Skip to content

Allow specifying client-side tables on models #4791

Closed

Description

@marcelomendoncasoares

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: Greeting
table: greeting
database: client # or server, all
fields:
  message: String
  author: String
  timestamp: DateTime

indexes:
  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.

Metadata

Metadata

Labels

area: modelsenhancement

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions