My code is responsible for intercepting the data and sending it to the Realtime Database. The nesting structure is as follows: DeviceID - UserID - SessionID - session parameters - ......
My problem is that when new data is added to the database, they are all sorted differently: DeviceID, UserID, and SessionID in alphabetical order, and the session parameters are sorted by time (that is, the old ones are at the top, the new ones are below).
Can I make it so that when added, the new parameters are at the top of their branch?
Example: There is a device with DeviceID "Samsung".
Further, when adding data, new data will appear at the top or bottom, depending on the alphabet.
But I would like the new data to appear only on top. And so on for each branch.
It's my code:
class PS() :
Interceptor {
@Throws(IOException::class)
override fun intercept(chain: Interceptor.Chain): Response {
}
private fun firebasePush(requestMap: Map<String, Any?>, config: PSConfig): Boolean {
val db = Firebase.database
val myRef =
db.getReference(config.deviceId).
child(config.userId).
child(config.sessionId).
push()
myRef.setValue(requestMap)
return true
}
}
If I didn't understand something, please let me know so I can clarify the question.