Objectbox fetching from db is showing out of date information

93 views Asked by At

I have been using object box seamlessly for 3 years. I modified one of my objects by adding an extra parameter called "public" which is a boolean value. When I store the object in the db the value is true. When I fetch the object from the db it is false

    private fun storeChannelsInDb(channels: List<Models.Channel>) {
    channels.forEach { channel ->
        val channelMapped = ChannelMapper.toObjectBoxModel(channel)
        channelBox.box.put(channelMapped)
        if(channelMapped.channel_id == 7 ){
            println("********* storing "+ channelMapped.public)
        }
    }
}

override fun getChannels(): List<Channel> {
    for (channel in channelBox.box.all){
        if(channel.channel_id == 7){
            println("********* fetching  "+ channel.public)
        }
    }
    return channelBox.box.all
}

enter image description here

I don't provide a default value for this parameter as it is always returned from the api. I fetch these objects on launch of the app and empty the box before adding them.

I've tried adding delays etc but always returning false. Even when I provide a default value of true it is returning false. Any suggestions would be greatly appreciated

1

There are 1 answers

2
nt95 On BEST ANSWER

The issue was "public" being a protected word. Changing the name solved the issue thanks to the comment from @user:551269