-
Notifications
You must be signed in to change notification settings - Fork 37
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
Adds query to transaction and refactor transaction to reuse the get etc functions #102
base: v8
Are you sure you want to change the base?
Conversation
@@ -426,7 +392,10 @@ export async function transaction< | |||
t.delete(firebaseDoc) | |||
} | |||
|
|||
return readFunction({ get }).then((data) => | |||
return readFunction({ | |||
get: (...props) => (getCommon as any)(props[0], props[1], props[2], {a, t}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to as any
because all those generics and overloads of get weren't matching, but it's the same params order. Tried to get it working without the type cast but hadn't success.
Also, I props[0], props[1], props[2]
instead of ...props
because some of them are optional and would make {a, t}
be in the wrong param instead of the forth one.
Queries can be used in transactions if running on server, as I read and tried (haven't tried on client yet but working on server). #6 #95
Also, as you mentioned in the code, you rewrote the get etc functions inside the transaction.
typesaurus/src/transaction/index.ts
Lines 308 to 311 in e4c2fa3
I have made a quick workaround so both get() and transaction's get() uses the same common function. Done the same for query(). It can also be done for the other transaction functions but won't do it until you think it's a good idea.
This branch is working but leaving as a Draft until further discussion and maybe improvements.