Firebase @Exclude with kotlin data class

后端 未结 2 1747
被撕碎了的回忆
被撕碎了的回忆 2021-01-07 19:21

I have this data class in Kotlin (example):

import com.google.firebase.database.Exclude

data class User(val name: String = \"\", @Exclude val age: Int = 0)
         


        
2条回答
  •  花落未央
    2021-01-07 19:58

    Actually you don't need to add only @get:Exclude but you need all 3 Exclude,

    @Exclude @set:Exclude @get:Exclude.

    I did it for imageUrl and providerId

    data class FirebaseChatModel(
            @get:PropertyName("message")
            @set:PropertyName("message")
            var message: String = "",
            @get:PropertyName("type")
            @set:PropertyName("type")
            var type: Int = 1,
            @get:PropertyName("senderId")
            @set:PropertyName("senderId")
            var senderId: Int = 0,
            @get:PropertyName("receiverId")
            @set:PropertyName("receiverId")
            var receiverId: Int = 0,
            @Exclude @set:Exclude @get:Exclude var imageUrl: String? = "",
            @Exclude @set:Exclude @get:Exclude var providerId: Int = 0
    )
    

提交回复
热议问题