-
Notifications
You must be signed in to change notification settings - Fork 0
Data Structures
Out of date. We're moving fast
How our app handles data and what structures it uses.
{
users: [], // list of user UUIDs
name: '', // name of the chat
id: '', // UUID of the chat
timestamp: r.now() // RethinkDbs date datatype
}
Simple enough.
{
id: '', // UUID of the message
message: '', // the contents of the message
chatId: '', // UUID of the chat it is part of
user: '', // UUID of the user who sent the message
timestamp: '' // string with the time the message was created
}
This entire object is then made a string via JSON.stringify
and sent over Redis' pubsub system. Most of this is simple except for the timestamp. The timestamp is created at the time nodejs created the message, and is created by taking a new Date()
and making it a string (date.toString()
).
When the message is received by other node servers, they should be made into objects again with JSON.parse()
and the timestamp should then be converted back to an object with message.timestamp = Date(message.timestamp)
{
id: '', // UUID of the message
message: '', // the contents of the message
chatId: '', // UUID of the chat it is part of
user: '', // UUID of the user who sent the message
username: '', // username of the user who sent the message
timestamp: r.now() // Rethinkdb's way of storing dates
}
This is very similar to the way messages are sent through Redis, but it has some key differences. It is stored as a json document (so it never has to be converted to a string), and the timestamp is a special datatype in Rethinkdb (millisecond precision).
Not finished
{
googId: '', // the users Google given ID
googName: '', // the users name as stored in Google
googImgUrl: '', // the URL of the users profile pic stored in Google
googProfUrl: '', // URL of the users Google profile
username: '', the users JetStream username
firstName: '', the users first name
lastName: '', the users last name
password: '', the users hashed password
salt: '', // the salt for the password hash
chatList: [], // a list of all the chat IDs that a user is a part of
id: '' // JetStream given UUID
}
Users have a bulk of the data about them.