Exclude

@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = [ElementType.METHOD, ElementType.FIELD])
annotation Exclude


Marks a field as excluded from the database instance.

Kotlin Note

When applying this annotation to a property of a Kotlin class, the @get use-site target should always be used. There is no need to use the @set use-site target as this annotation is only considered when writing instances into Firestore, and is ignored when reading instances from Firestore.

Here is an example of a class that can both be written into and read from Firestore whose bar property will never be written into Firestore:

dataclassPojo(varfoo:String?=null,@get:Excludevarbar:String?=null){constructor():this(null,null)// Used by Firestore to create new instances}

If the class only needs to be written into Firestore (and not read from Firestore) then the class can be simplified as follows:

dataclassPojo(valfoo:String?=null,@get:Excludevalbar:String?=null)
That is, var can be tightened to val and the secondary no-argument constructor can be omitted.