简体   繁体   中英

Flutter Firestore update Documents

I have an App where the user can buy Tickets. And in Firestore the Tickets are represented by documents so each ticket has it's own document. What I want to do is when the user wants to buy 5 Tickets I need a way to pick 5 random documents where the status is available and set them to sold. Is there a specific way to do that?

You can retrieve 5 random tickets with a Firestore-query with.limit(5) in a list. After that you can loop to the list and get the id of each ticket and update each ticket to status "sold".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM