Hello,
I have a scenario like the following: many people enter a game at the same time, but the game is limited to 100 players. Given that example, how would I handle these two steps?:
1: Querying entry count to ensure it isn’t too large
2: Adding a player to the database’s entry collection
Using a traditional database with Entity Framework, I would just wrap it in a transaction scope, but I’m not sure about Squidex.
I’m using the .NET library.
You need another schema where you just save the count. You can then query the count first and increment using optimistic concurrency (not supported by .NET library right now) to increment the value. When it succeeds you add an entry to your player list or you retry.
https://docs.squidex.io/02-documentation/developer-guides/api-overview/api#versioning
Is there any workaround I can use in C# right now? Not sure how I would use that in conjunction with the. NET library.
This is kind of the burden with distributed systems that transactions are hard to implement. Your only choice would be to store all information about the game in a single document and then use optimistic concurrency. e.g. when you have a content type with an array of players or a json field you can use optimistic concurrency with retries.