Home > Blockchain >  differences between Realtime Database data types
differences between Realtime Database data types

Time:09-27

I am thinking about what actual format store in database?

like is there any diiferences between ref('data/timestamp').set(ServerValue.timestamp) and ref('data').set({timestamp:ServerValue.timestamp})?

So does array and list are they exists for simplify client side code? or it's actually matter on database side? I am looking for the basic types that acatual store in database.

CodePudding user response:

There is no difference in the value of the timestamp node that both fragments store in the database. In both cases that value will be a long numeric value, indicating the number of milliseconds since the epoch.

The difference is in what happens to any existing other nodes you may have under data already. Say that you start with:

data: {
  name: "flutroid",
  timestamp: 0
}

Then running ref('data/timestamp').set(ServerValue.timestamp) will lead to:

data: {
  name: "flutroid",
  timestamp: 1664028303669
}

While running ref('data').set({timestamp:ServerValue.timestamp}) leads to:

data: {
  timestamp: 1664028303669
}

So in this last example the name node (and any other nodes under data) were deleted and only timestamp remains.

  • Related