Firebase Schema

Chat SDK v5 - Example Firebase JSON

This JSON shows a typical Firebase database schema with one chat thread with one message. Two users, one of which has the other user as a contact and also blocked.

{
"threads" : {
"-MBtATOUMrdVcf00dKM8" : {
"details" : {
"creation-date" : 1594392177181,
"creator" : "NX6mGPCkR3NcNiJJxBzNrsR2Anz2",
"creator-entity-id" : "NX6mGPCkR3NcNiJJxBzNrsR2Anz2",
"name" : "",
"type" : 2,
"type_v4" : 2
},
"messages" : {
"-MBtAUWXGAfptOca757W" : {
".priority" : 1594392181233,
"date" : 1594392181233,
"from" : "NX6mGPCkR3NcNiJJxBzNrsR2Anz2",
"meta" : {
"text" : "Hi"
},
"read" : {
"9tJUx1iT5LQ1bC1J952No6sNZjZ2" : {
"date" : 1594392181743,
"status" : 1
},
"NX6mGPCkR3NcNiJJxBzNrsR2Anz2" : {
"status" : 2
}
},
"to" : [ "9tJUx1iT5LQ1bC1J952No6sNZjZ2" ],
"type" : 0,
"user-firebase-id" : "NX6mGPCkR3NcNiJJxBzNrsR2Anz2"
}
},
"meta" : {
"creation-date" : 1594392176550,
"creator" : "NX6mGPCkR3NcNiJJxBzNrsR2Anz2",
"creator-entity-id" : "NX6mGPCkR3NcNiJJxBzNrsR2Anz2",
"name" : "",
"type" : 2,
"type_v4" : 2
},
"users" : {
"9tJUx1iT5LQ1bC1J952No6sNZjZ2" : {
"status" : "member"
},
"NX6mGPCkR3NcNiJJxBzNrsR2Anz2" : {
"status" : "owner"
}
}
}
},
"users" : {
"9tJUx1iT5LQ1bC1J952No6sNZjZ2" : {
"last-online" : 1594392150028,
"meta" : {
"availability" : "available",
"email" : "[email protected]",
"name" : "Andy",
"name-lowercase" : "andy",
"pictureURL" : "http://identicon.sdk.chat?value=9tJUx1iT5LQ1bC1J952No6sNZjZ2&size=400.png"
},
"online" : true,
"threads" : {
"-MBtATOUMrdVcf00dKM8" : {
"invitedBy" : "NX6mGPCkR3NcNiJJxBzNrsR2Anz2"
}
}
},
"NX6mGPCkR3NcNiJJxBzNrsR2Anz2" : {
"blocked" : {
"9tJUx1iT5LQ1bC1J952No6sNZjZ2" : {
"uid" : "9tJUx1iT5LQ1bC1J952No6sNZjZ2"
}
},
"contacts" : {
"9tJUx1iT5LQ1bC1J952No6sNZjZ2" : {
"type" : 0
}
},
"last-online" : 1594391749332,
"meta" : {
"availability" : "available",
"email" : "[email protected]",
"name" : "Ben",
"name-lowercase" : "ben",
"pictureURL" : "http://identicon.sdk.chat?value=NX6mGPCkR3NcNiJJxBzNrsR2Anz2&size=400.png"
},
"online" : true,
"threads" : {
"-MBtATOUMrdVcf00dKM8" : {
"invitedBy" : "NX6mGPCkR3NcNiJJxBzNrsR2Anz2"
}
}
}
}
}

Firestream Example JSON

{
"chats" : {
"-MCw525wN7BBuycJ5UX0" : {
"messages" : {
"-MCw53dwaUZqimC0b-yC" : {
".priority" : 1595514833932,
"body" : {
"text" : "0",
"type" : ""
},
"date" : 1595514833932,
"from" : "liedgpMs2thMhkZjphkc3dH5VcV2",
"type" : "message"
}
},
"meta" : {
"created" : 1595514827588,
"data" : {
"Key2" : 999,
"TestKey" : "TestValue"
},
"image-url" : "https://chatsdk.co/wp-content/uploads/2017/01/image_message-407x389.jpg",
"name" : "Test"
},
"users" : {
"6TB34PbMqdU67KHvIuGrekMCIOk2" : {
"role" : "banned"
},
"9tJUx1iT5LQ1bC1J952No6sNZjZ2" : {
"role" : "admin"
},
"liedgpMs2thMhkZjphkc3dH5VcV2" : {
"role" : "owner"
}
}
}
},
"users" : {
"6TB34PbMqdU67KHvIuGrekMCIOk2" : {
"messages" : {
"-MCw52Fu3NEUszVjFYfn" : {
".priority" : 1595514828219,
"body" : {
"id" : "-MCw525wN7BBuycJ5UX0",
"type" : "chat"
},
"date" : 1595514828219,
"from" : "liedgpMs2thMhkZjphkc3dH5VcV2",
"type" : "invitation"
}
}
},
"liedgpMs2thMhkZjphkc3dH5VcV2" : {
"chats" : {
"-MCw525wN7BBuycJ5UX0" : {
"date" : 1595514828551
}
}
}
}
}