To exclude a field/property from Firebase, you need to use @get:Exclude
.
class Test( var name: String = "", @get:Exclude val isLocalFlag: Boolean = true) { @get:Exclude val notLocalFlag: Boolean get() = !isLocalFlag}
@IgnoreExtraProperties
and @Exclude
doesn't seems to work, probably because getter is generated by Kotlin.
NOTE: Firestore Annotations
@IgnoreExtraPropertiesclass Test( @Exclude val excludeNotWorking: Boolean = true, // fail @get:Exclude val isLocalFlag: Boolean = true) { val ignoreExtraPropertiesNotWorking: Boolean // fail get() = !isLocalFlag @get:Exclude val notLocalFlag: Boolean get() = !isLocalFlag}
If you have kotlin function which return value, @Exclude
annotation is required as well to prevent those value to be saved.
class Test( val publishStatus: Int = 0, val isActive: Boolean = true) { @Exclude fun getStatusText(): String { return if (isActive) "ACTIVE" else "INACTIVE" } @Exclude fun isImutable(): Boolean { return publishStatus == 1 }}