aquametalabs / aquameta

Web development platform built entirely in PostgreSQL
GNU General Public License v3.0
1.1k stars 52 forks source link

endpoint: Server-side bundle awareness #228

Open erichanson opened 3 years ago

erichanson commented 3 years ago

Right now, the REST API is just an interface to view/change the state of things right now (CRUD). But with version control now in place, there's a lot more awareness and intelligence available to integrate in. We need to integrate bundle-awareness into endpoint, generally. #72 touches on it but it is just the tip of the iceberg.

Examples of where it would be nice/essential:

Operational changes:

row_insert / rows_insert

Needs the ability to specify that the new row should be tracked, staged, or maybe even committed, and by which bundle. Track-on-insert is very often the desired behavior. Stage-on-insert is less common but seems like it could be useful. Commit-on-insert is weird, but we might as well make the option available for say a streaming database or a commit-based chat.

The above could also be accomplished, alternately, by setting up table-wide auto-tracking rules: "All inserts into this table are tracked by this bundle." Not sure this is a good idea though, because nobody "owns" a particular media type. Could be useful in a single user environment.

row_update

Updating a row that is in a bundle (tracked) could auto-stage the update. Not much here.

row_delete / rows_delete

Deleting could also auto-stage the delete. Also uninteresting.

row_select / rows_select / field_select

endpoint.row_select() takes a row_id, but it could also take a commit_id to grab the value at a previous commit, or a modifier that says "give me the HEAD version, not the working copy version." It could take version ranges (once we have version tags), etc. rows_select takes an args object for things like where clauses, which would be very strange to handle because it would need to somehow run a where clause against a not-checked-out version. Might be challenging. Checkout + rollback?

rows_select_function

This could actually take a previous version of the function which would be pretty crazy. Not sure how to pull that off though. Or it could run against a previous version of the database. Also quite complex.