firebase/snippets-ios

Incrementing counter throws error

m-rtin opened this issue · 3 comments

The following function doesn't work:

func incrementCounter(ref: DocumentReference, numShards: Int) {
        // Select a shard of the counter at random
        let shardId = Int(arc4random_uniform(UInt32(numShards)))
        let shardRef = ref.collection("shards").document(String(shardId))

        shardRef.updateData([
            "count": FieldValue.increment(Int64(1))
        ])
    }

The FieldValue.increment(Int64(1)) part throws the following error:

Unsupported type: FSTNumericIncrementFieldValue (found in field count) (FIRInvalidArgumentException)

@samtstern do you know what's going on here?

@morganchen12 nope but we should probably move this over to the iOS SDK repo,

@m-rtin can you share the debug logs from when this error happens? You can enable debug logging with this method.