Shape support for selecting columns #1676
Replies: 4 comments 7 replies
-
Just for more context: Electric syncs data using Shapes. Shapes target rows in a curl http://localhost:300/v1/shapes/users?where="age<25" By default, Shapes return the whole row. In this case, the row would contain all columns in the In these cases, you would ideally want to be able to sync users where you either select (i.e.: whitelist to include) or ignore (i.e.: blacklist to not include) specific columns. ImplementationThis can be supported using |
Beta Was this translation helpful? Give feedback.
-
Just some random thoughts re deriving efficiency gains from user's shape definitions. We can edit a table's Another thing to consider is pruning unused bytes early on when processing logical messages in Electric. Right now we decode logical messages from raw bytes into Elixir maps in full. But if we can inform the decoder about which columns are SELECTed by the union of all shapes referencing the table, it will be able to skip unreferenced columns and avoid carrying them around for other processing steps, including shape storage. |
Beta Was this translation helpful? Give feedback.
-
We've done tests using our production database and this feature is required for us to use Electric for parts of our app. We only want to sync a few columns and don't want to sync other large columns because the data becomes too big. |
Beta Was this translation helpful? Give feedback.
-
We already have a where clause, why not have a select clause as well:
Benefits:
|
Beta Was this translation helpful? Give feedback.
-
This is a common request.
People will also want to rename columns (
SELECT column AS foo
)HTTP API
There's no universal way to represent arrays in urls — especially if it's not a simple array as here but can have sub-objects. So let's just JSON.stringify the data and add it as a
columns
parameter. E.g.curl http://localhost:3000/v1/shapes/foo?columns=?columns=["id",{"name":"title","alias":"title_v1"},"created_at"]
Generally clients would url encode the json to ensure full compatibility but handwriting locally works as well.
Beta Was this translation helpful? Give feedback.
All reactions