Home > Software engineering >  All field name in firestore be added "$app_debug" strings automatically
All field name in firestore be added "$app_debug" strings automatically

Time:11-10

I don't know why all field in my document have the $app_debug in the end of name like this

Update: Shop is created this way

     private var shop = Shop()
     with(binding) {
            shop.name = edtName.text.toString()
            shop.address = edtAddress.text.toString()
            shop.phone = edtPhone.text.toString()
            shop.openTime = edtOpenTime.text.toString()
            shop.website = edtWebsite.text.toString()
            shop.owner = edtOwner.text.toString()
            shop.imageUrl = imageUrl
        }
    shop.pendingApprove = true
    shop.created = false
    shop.lastModifiedTime = Calendar.getInstance().timeInMillis.toDouble()

Here is my way to put data to firestore

db.collection(SHOP_PENDING_COLLECTION)
                .document(Firebase.auth.uid)
                .set(shop)
                .addOnSuccessListener {
                    hideProgressbar()
                    startActivity(Intent(this@AddNewShopActivity, ShopMainActivity::class.java).apply {
                        putExtra(EXTRA_CREATED_SHOP, "created")
                    })
                    finish()
                }
                .addOnFailureListener { e ->
                    hideProgressbar()
                    Utils.showShortToast(
                        this@AddNewShopActivity, getString(R.string.fail_to_create_shop)
                    )
                    Log.e(ContentValues.TAG, "Error adding document", e)
                }

and my Shop.kt model

@Parcelize data class Shop(
    internal var uid: String? = null,
    internal var name: String? = null,
    internal var owner: String? = null,
    internal var address: String? = null,
    internal var phone: String? = null,
    internal var openTime: String? = null,
    internal var website: String? = null,
    internal var imageUrl: String? = null,
    internal var service: String? = null,
    internal var rating: Double? = null,
    internal var reviewCount: Long? = null,
    internal var location: @RawValue HashMap<String, Any>? = null,
    internal var pendingApprove: Boolean? = null,
    internal var created: Boolean? = null,
    internal var lastModifiedTime: Double? = null,
    internal var fcmToken: String? = null
) : Parcelable

I was trying to looking solution but can't find anywhere. I would appreciate any help!

CodePudding user response:

If you want to serialize and deserialize objects when using Firestore, then you can simply use Kotlin data classes. This means that there is no need to add internal in front of the fields and there is also no need to use an @Parcelize annotation.

  • Related