#✅ - GraphQL API - extract length of array field

8 messages · Page 1 of 1 (latest)

hexed maple
#

AFAIK there is no other way that querying all the related models and counting them. Of course you could also implement a counter for model A, where you would keep track of amount of related B -elements. This would be fairly straight forward with DDB streams for example ( every time a B is created or removed, a Lambda is invoked which would then update the counter on related A)

#

You could use Condition expressions to overcome that.

#

Yeah 🙂

#

But in short with conditional updates you can make sure a certain value is what you expect it to be at the time of an update, so race conditions shouldn't be possible.

#

Indeed!

#

If you want to keep accurate track of the number, perhaps you would also want to use SQS queue. So that if the incrementing operation fails for one reason or another, you could leverage the DLQ (where failed events will eventually end up at) to process that again later.

But this would probably be overkill at this point for you 😄

sonic oceanBOT
#

✅ - GraphQL API - extract length of array field