server/db/rethinkdb/schema.md
tinodeusersStores user accounts
Fields:
Id user id, primary keyCreatedAt timestamp when the user was createdUpdatedAt timestamp when user metadata was updatedState account state: normal (ok), suspended, soft-deletedStateAt timestamp when the state was last updated or NULLAccess user's default access level for peer-to-peer topicsAuth, Anon default permissions for authenticated and anonymous usersPublic application-defined dataState state of the user: normal, disabled, deletedStateAt timestamp when the state was last updated or NULLLastSeen timestamp when the user was last onlineUserAgent client User-Agent used when last onlineTags unique strings for user discoveryDevices client devices for push notificationsDeviceId device registration IDPlatform device platform string (iOS, Android, Web)LastSeen last logged inLang device language, ISO codeIndexes:
Id primary keyTags multi-index (indexed array)DeletedAt indexDeviceIds multi-index of push notification tokensSample:
{
"Access": {
"Anon": 0 ,
"Auth": 47
} ,
"CreatedAt": Mon Jul 24 2017 11:16:38 GMT+00:00 ,
"State": 0,
"StateAt": null ,
"Devices": null ,
"Id": "7yUCHniegrM" ,
"LastSeen": Mon Jan 01 1 00:00:00 GMT+00:00 ,
"Public": {
"fn": "Alice Johnson" ,
"photo": {
"data": <binary, 6.5KB, "ff d8 ff e0 00 10..."> ,
"type": "jpg"
}
} ,
"State": 1 ,
"Tags": [
"email:[email protected]" ,
"tel:17025550001"
] ,
"UpdatedAt": Mon Jul 24 2017 11:16:38 GMT+00:00 ,
"UserAgent": "TinodeWeb/0.13 (MacIntel) tinodejs/0.13"
}
authStores authentication secrets
Fields:
userid ID of the user who owns the recordunique unique string which identifies this record, primary key; defined as "authentication scheme':'some unique value per scheme"secret shared secret, for instance bcrypt of passwordauthLvl authentication levelexpires timestamp when the records expiresIndexes:
unique primary keyuserid indexSample:
{
"authLvl": 20 ,
"expires": Mon Jan 01 1 00:00:00 GMT+00:00 ,
"secret": <binary, 60 bytes, "24 32 61 24 31 30..."> ,
"unique": "basic:alice" ,
"userid": "7yUCHniegrM"
}
topicsThe table stores topics.
Fields:
Id name of the topic, primary keyCreatedAt topic creation timeUpdatedAt timestamp of the last change to topic metadataState topic state: normal (ok), suspended, soft-deletedStateAt timestamp when the state was last updated or NULLAccess stores topic's default access permissionsAuth, Anon permissions for authenticated and anonymous users respectivelyOwner ID of the user who owns the topicPublic application-defined dataState state of the topic: normal, disabled, deletedSeqId sequential ID of the last messageDelId topic-sequential ID of the deletion operationUseBt indicator that channel functionality is enabled in the topicIndexes:
Id primary keyOwner indexSample:
{
"Access": {
"Anon": 64 ,
"Auth": 64
} ,
"DelId": 0,
"CreatedAt": Thu Oct 15 2015 04:06:51 GMT+00:00 ,
"State": 0 ,
"StateAt": null ,
"LastMessageAt": Sat Oct 17 2015 13:51:56 GMT+00:00 ,
"Id": "p2pavVGHLCBbKrvJQIeeJ6Csw" ,
"Owner": "v2JyG4OLSoA" ,
"Public": {
"fn": "Travel, travel, travel" ,
"photo": {
"data": <binary, 6.2KB, "ff d8 ff e0 00 10..."> ,
"type": "jpg"
}
} ,
"SeqId": 14,
"State": 0 ,
"UpdatedAt": Thu Oct 15 2015 04:06:51 GMT+00:00 ,
"UseBt": false
}
subscriptionsThe table stores relationships between users and topics.
Fields:
Id used for object retrievalCreatedAt timestamp when the subscription was createdUpdatedAt timestamp when the subscription was updatedDeletedAt timestamp when the subscription was deletedReadSeqId id of the message last read by the userRecvSeqId id of the message last received by any user deviceDelId topic-sequential ID of the soft-deletion operationTopic name of the topic subscribed toUser subscriber's user IDModeWant access mode that user wants when accessing the topicModeGiven access mode granted to user by the topicPrivate application-defined data, accessible by the user onlyIndexes:
Id primary key composed as "topic name':'user ID"User indexTopic indexSample:
{
"ClearId": 0 ,
"CreatedAt": Tue Jul 25 2017 15:34:39 GMT+00:00 ,
"DeletedAt": null ,
"Id": "grpjajVKrHn0PU:v2JyG4OLSoA" ,
"ModeGiven": 47 ,
"ModeWant": 47 ,
"Private": "Kirgudu" ,
"ReadSeqId": 0 ,
"RecvSeqId": 0 ,
"State": 0 ,
"Topic": "grpjajVKrHn0PU" ,
"UpdatedAt": Tue Jul 25 2017 15:34:39 GMT+00:00 ,
"User": "v2JyG4OLSoA"
}
messagesThe table stores {data} messages
Fields:
Id currently unused, primary keyCreatedAt timestamp when the message was createdUpdatedAt initially equal to CreatedAt, for deleted messages equal to DeletedAtDeletedFor array of user IDs which soft-deleted the messageDelId topic-sequential ID of the soft-deletion operationUser ID of the user who soft-deleted the messageFrom ID of the user who generated this messageTopic which received this messageSeqId messages ID - sequential number of the message in the topicHead message headersAttachments denormalized IDs of files attached to the messageContent application-defined message payloadIndexes:
Id primary keyTopic_SeqId compound index ["Topic", "SeqId"]Topic_DelId compound index ["Topic", "DelId"]Topic_DeletedFor compound multi-index ["Topic", "DeletedFor"("User"), "DeletedFor"("DelId")]Sample:
{
"Content": {
"fmt": [
{
"len": 6 ,
"tp": "ST"
}
] ,
"txt": "Hello!"
} ,
"CreatedAt": Sun Dec 24 2017 05:16:23 GMT+00:00 ,
"From": "wTI0jO9rEqY" ,
"Head": {
"mime": "text/x-drafty"
} ,
"DeletedFor": [
{
"DelId": 1 ,
"User": "wTI0jO9rEqY"
}
] ,
"Id": "LLXKEe9W4Bs" ,
"SeqId": 3 ,
"Topic": "p2pJhbJnya8z5PBMjSM72sSpg" ,
"UpdatedAt": Sun Dec 24 2017 05:16:23 GMT+00:00
}
dellogThe table stores records of message deletions
Fields:
Id currently unused, primary keyCreatedAt timestamp when the record was createdUpdatedAt timestamp equal to CreatedAtDelId topic-sequential ID of the deletion operation.DeletedFor ID of the user for soft-deletions, blank string for hard-deletionsTopic affected topicSeqIdRanges array of ranges of deleted message IDs (see messages.SeqId)Indexes:
Id primary keyTopic_DelId compound index ["Topic", "DelId"]Sample:
{
"Id": "9LfrjW349Rc",
"CreatedAt": Tue Dec 05 2017 01:51:38 GMT+00:00,
"DelId": 18,
"DeletedFor": "xY-YHx09-WI" ,
"SeqIdRanges": [
{
"Low": 20,
"Hi": 25,
}
] ,
"Topic": "grpGx7fpjQwVC0" ,
"UpdatedAt": Tue Dec 05 2017 01:51:38 GMT+00:00
}
credentialsThe tables stores user credentials used for validation.
Id credential, primary keyCreatedAt timestamp when the record was createdUpdatedAt timestamp when the last validation attempt was performed (successful or not).Method validation methodDone indicator if the credential is validatedResp expected validation responseRetries number of failed attempts at validationUser id of the user who owns this credentialValue value of the credentialClosed unvalidated credential is no longer being validated. Only one credential is not Closed for each user/method.Indexes:
Id Primary key composed either as User:Method:Value for unconfirmed credentials or as Method:Value for confirmed.User IndexSample:
{
"Id": "tel:+17025550001",
"CreatedAt": Sun Jun 10 2018 16:37:27 GMT+00:00 ,
"UpdatedAt": Sun Jun 10 2018 16:37:28 GMT+00:00 ,
"Method": "tel" ,
"Done": true ,
"Resp": "123456" ,
"Retries": 0 ,
"User": "k3srBRk9RYw" ,
"Value": "+17025550001"
}
fileuploadsThe table stores records of uploaded files. The files themselves are stored outside of the database.
Id unique user-visible file name, primary keyCreatedAt timestamp when the record was createdUpdatedAt timestamp of when th upload has cmpleted or failedUser id of the user who uploaded this file.Location actual location of the file on the server.MimeType file content type as a Mime string.Size size of the file in bytes. Could be 0 if upload has not completed yet.UseCount count of messages referencing this file.Status upload status: 0 pending, 1 completed, -1 failed.Indexes:
Id primary keyUseCount indexSample:
{
"CreatedAt": Sun Jun 10 2018 16:38:45 GMT+00:00 ,
"Id": "sFmjlQ_kA6A" ,
"Location": "uploads/sFmjlQ_kA6A" ,
"MimeType": "image/jpeg" ,
"Size": 54961090 ,
"UseCount": 3,
"Status": 1,
"UpdatedAt": Sun Jun 10 2018 16:38:45 GMT+00:00 ,
"User": "7j-RR1V7O3Y"
}