How to ignore/exclude fields on model on Firestore

My current goal is to send some useful data to my Firestore database. The problem is that I keep seeing the ignore fields on it.

I do not have any need to keep the boolean ‘isUserAuthenticated’ and ‘isNewUser’ on the database.

For the fields, I do not want to keep I am adding an @Exclude and I am even tried to use @ IgnoreExtraProperties on top of the class.

An except from the model:

class UserModel : Serializable {
    // authentication logic

    var isUserAuthenticated = false

This is an excert that shows how I send it:

val profile = UserModel(

        val uidRef: DocumentReference = firebaseUser.let { usersRef.document(it.uid) }

        uidRef.get().addOnCompleteListener { uidTask: Task<DocumentSnapshot> ->
            if (uidTask.isSuccessful) {
                Log.i(TAG, "createProfileInFirestore: uidTask.isSuccessful()")
                try {
                    val document: DocumentSnapshot = uidTask.result
                    if (!document.exists()) {
                            .addOnCompleteListener { profileCreationTask: Task<Void> ->

In Java the ignore fields worked but I am currently rewriting it in Kotlin.

>Solution :

The @Exclude annotation added in front of the public field works in Java. In Kotlin, you have to add @get:Exclude like this:

var isUserAuthenticated = false

Leave a Reply