Thanks gary. I guess rpc postgres would be the bes...
# sql
d
Thanks gary. I guess rpc postgres would be the best choice so I don't need to pull extra load from the db or have redundant data in my db.
s
@garyaustin @daviscup You can also use computed columns for this, they won't be stored in the db and are shorter than a full setof returning function:
Copy code
CREATE FUNCTION trimmed(your_tbl) RETURNS text AS $$
  SELECT left(45, $1.text);
$$ LANGUAGE SQL;
Then you can use it inside
select('uid,trimmed,..)
. https://postgrest.org/en/stable/api.html#computed-columns
g
@User I thought in Postgres they only support stored columns so do take up space.
s
> PostgreSQL currently implements only stored generated columns. (https://www.postgresql.org/docs/current/ddl-generated-columns.html) @garyaustin Note that that's only when using the "generated columns" feature. Computed columns have been there for a while, Check the last part of the following section(keyword is "computed fields"): > This equivalence between functional notation and field notation makes it possible to use functions on composite types to implement “computed fields”. https://www.postgresql.org/docs/current/rowtypes.html#ROWTYPES-USAGE
Maybe we should use the term "computed fields" to match the postgresql terminology. I'll also make a similar change on the postgREST docs side.