Filipe Nunes
Filipe Nunes

Reputation: 11

PropertyName in Cloud Firestore does not work with Kotlin

The annotation @PropertyName is not serialized in Kotlin!

Version: com.google.firebase: firebase-firestore: 17.1.0

Using @PropertyName in a Kotlin Android project, it does not serialize the value, only when I use annotation @JVMField or create the same class in Java.

@JvmField
@PropertyName("championship-name")
val championshipName: String = "",

Upvotes: 1

Views: 1445

Answers (2)

Max
Max

Reputation: 788

You can achieve this without making the property mutable, just annotate the getter with @PropertyName:

@get:PropertyName("championship-name") 
val championshipName: String = "",

Upvotes: 1

Rajasekaran M
Rajasekaran M

Reputation: 2538

Try like this

@get:PropertyName("championship-name") @set:PropertyName("championship-name") var championshipName: String = "",

Upvotes: 7

Related Questions