Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insert across tables #5

Closed
vwkd opened this issue Jun 18, 2023 · 1 comment
Closed

Insert across tables #5

vwkd opened this issue Jun 18, 2023 · 1 comment
Labels
enhancement New feature or request wontfix This will not be worked on

Comments

@vwkd
Copy link
Owner

vwkd commented Jun 18, 2023

Insert across tables in one atomically consistent set. Receives deep object as input, walks from deepest leaves to root, inserts each object into corresponding table.

But how should report the ids and versionstamps of the nested rows? Array of Result with additional table name entry?

Deep insert is complex to implement, needs to pick apart deep input object, generate the ids and match them up, just to stitch it back together at query time later. It largely defeats the purpose of relational data storage, since can't link new data to existing data, must always insert together, could almost just store the whole data as JSON if not for ability to query only part of it. Also cumbersome for user to define duplicate type hierarchy for input types and output types.

Better to let user build the relations. Just somehow ensure consistency... Would need to give up generating ids for user, instead let the user generate random UUIDs in advance, allow to insert multiple at same time, throw if any id already exists.

Could accept multiple rows in a mutation, and multiple mutations in a request. The mutations must all be committed in one atomic transaction. Order doesn't matter since there are no foreign key constraints in Deno KV, and atomicity makes either all succeed or all fail. Inserting valid references is up to the user?

mutation {
  createBooks(data: [ { id: "xxx", ..., author: "bbb" }, { id: "yyy", ..., author: "aaa"} ]) Result @insert(table: "Book")
  createAuthors(data: [ { id: "aaa", ... }, { id: "bbb", ... } ]) Result @insert(table: "Author")
}
@vwkd
Copy link
Owner Author

vwkd commented Jun 21, 2023

It's now possible to insert consistently in one atomic transaction with bb3eccd

We leave it to the user to separate nested data into the tables to not take away control and also keep complexity down.

@vwkd vwkd closed this as completed Jun 21, 2023
@vwkd vwkd added wontfix This will not be worked on enhancement New feature or request labels Jul 15, 2023
@vwkd vwkd reopened this Jul 15, 2023
@vwkd vwkd closed this as not planned Won't fix, can't repro, duplicate, stale Jul 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant