-
Notifications
You must be signed in to change notification settings - Fork 3
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
transaction function not available on repos #38
Comments
Hi @hschk That's correct, the docs aren't up-to-date with transactions. They've been made independent of repos. Here's an example: await firestore.runTransaction(async (t) => {
const trx = new FirestoreTransaction(firestore, t);
const user = await trx.get(userRepo, { userId: '123' });
trx.update(userRepo, { id: user.id, email: '[email protected]' });
}); Depending on your setup you can use this helper function to run transactions function runTransaction(cb: (trx: FirestoreTransaction) => Promise<any>) {
return firestore.runTransaction((trx) => {
return cb(new FirestoreTransaction(firestore, trx));
});
} If you have anymore questions, just let me know |
Thank you very much for your answer!
The create method requires an argument for 'ids'. Why and how do I have to pass this? With the "normal" create method of the repo I don't have to pass this. |
If your collection is a root collection and not a subcollection, it could be that the typing is not correct. Try passing |
Yes, it does work with undefined, even though that doesn't feel perfect ^^ Why would the typing not be correct? Did I configure something wrong here? I have another question, that is more important to me: Is it somehow possible to query a FirestoreTransaction not only by id but as "normal" query like you can do on a normal firestore-storage repo?
|
@hschk thanks for your patience. No, you didn't configure anything wrong, it's just a typing issue with the package itself. Regarding your seconds question: You're actually correct. The transaction methods should match the repo methods. I deprecated const accounts = await trx.query(
accountRepo,
(qb) => {
return qb.whereAll({
someField: 'value',
});
},
undefined
); |
In the docs it says that every repo provides a transaction function, but it seems that it's not there.
Am I doing something wrong, or are the docs not up to date?
The text was updated successfully, but these errors were encountered: