You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I followed the docs snd setup a distributed counter in one of my collections. I have this rule:
match /databases/{database}/documents/messages/{page} {
// Allow to increment only the 'count' field and only by 1.
match /_counter_shards_/{shardId} {
allow get;
allow write: if request.resource.data.keys() == ["count"]
&& (resource == null || request.resource.data.count ==
resource.data.count + 1);
}
}
In my client app (iOS swift), I created this instance:
func increment {
var db = Firestore.firestore()
// create reference to the collection and the document you wish to use
var doc = db.collection("messages").document("_counts_document_")
let instance = FirebaseDistributedCounter(docRef: doc, field: "count")
instance.increment(by: 1.0)
}
I set the Frequency for controllerCore function to be run to 5 mins.
But whenever I call increment once or in a loop for 10 times, counts_document.count is incrementing in realtime. Extension is not creating the sub-collections and the controllerCore function is not doing anything because there are no sub-collections. I saw them created once or twice but not more than that.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I followed the docs snd setup a distributed counter in one of my collections. I have this rule:
In my client app (iOS swift), I created this instance:
I set the Frequency for controllerCore function to be run to 5 mins.
But whenever I call
increment
once or in a loop for 10 times, counts_document.count is incrementing in realtime. Extension is not creating the sub-collections and the controllerCore function is not doing anything because there are no sub-collections. I saw them created once or twice but not more than that.Please let me know if I am missing anything.
Thank you in advance,
--Suman
Beta Was this translation helpful? Give feedback.
All reactions