Here’s a new feature for Data Tables for which we’ve received a few requests:
You can now create column-restricted views in Accelerated Tables!
That’s right, you can create a view object that only exposes certain columns of your table, and pass it back to client code. This is great for exposing only certain data to client code.
To use it, pass q.only_cols("column_name", "other_column", ...)
to your view function. So, for example, this server function allows client code to view only the email
and enabled
columns of the Users table, leaving all other data inaccessible:
@anvil.server.callable
def get_users():
return app_tables.users.client_readable(q.only_cols("email", "enabled"))
This can of course be combined with other view constraints, to columns that are or are not visible to the view user. For example:
app_tables.users.client_readable(q.only_cols("email"), enabled=True)
Go check out the documentation!
Particular props go out to @stucork for this one, with a few contributions from yours truly