Schema Definition

Rooms

1
{
2
"_id": "22nytdn4QqKvSk2Av", // Random.id()
3
"t": "p", // String Room Type: c = chanel, d = direct, p (change to g) = group, v = visitor
4
"ts": new Date(1432937851208), // Date Room Creation Timestamp
5
"name": "general", // String Room Name (t:d -> empty)
6
"lm": new Date(1432937851208), // Date Last Message Timestamp
7
"msgs": 2345, // Integer Messages Counter
8
"cl": true, // Boolean If users can leave room
9
"ro": false, // Boolean Read Only
10
"usernames": [ // Array(String) Room Users
11
"username1", // String User Username
12
"username2",
13
"username3"
14
],
15
"u": { // Object Owner User
16
"_id": "CABrXSHpDqbZXGkYR", // Random.id() User Id
17
"username": "john" // String User Username
18
},
19
"customFields": { // Object User defined custom fields (for t:c and t:p only)
20
"userDefinedField": "userValue", // User defined field example
21
"userDefinedField2": true, // User defined field example
22
"userObject3": { // User defined field example
23
"a": "hello",
24
"b": "lalala"
25
}
26
}
27
}
Copied!

Fields

Fields
Type
Description
_id
Random.id()
Room Id
t
String
Room Type
ts
Date
Room Creation Timestamp
name
String
Room Name (t:d -> empty)
lm
Date
Last Message Timestamp
msgs
Integer
Messages Counter
cl
Boolean
If users can leave room
ro
Boolean
Read Only
usernames
Array[String]
Room Users
usernames.0
String
User Username
u
Object
Owner User
u._id
Random.id()
User Id
u.username
String
User Username
customFields
Object
User custom fields (for t:c and t:p only)

Indexes

Fields
Options
name
unique, sparce
u._id

Subscriptions

1
{
2
"_id": "22nytdn4QqKvSk2Av", // Random.id()
3
"t": "p", // String Subscription Type (copy from Room)
4
"ts": new Date(1432937851208), // Date Subscription Creation Timestamp
5
"ls": new Date(1432937851208), // Date Last Seen Timestamp
6
"name": "my-cool-friends", // String Subscription Name (t:d -> target username)
7
"rid": "25fkmHMDeFp57ZqYg", // Random.id() Room Id
8
"f": true, // Boolean Favorited
9
"open": true, // Boolean Is Room Opened
10
"alert": true, // Boolean Room has unread messages for this user
11
"unread": 5, // Integer Counter of unread messages with mentions or from direct messages
12
"u": { // Object User
13
"_id": "CABrXSHpDqbZXGkYR", // Random.id() User Id
14
"username": "liam" // String User Username
15
},
16
"v": { // Object Visitor
17
"_id": "CABrXSHpDqbZXGkYR", // Random.id() Visitor Id
18
"username": "anonymous" // String Visitor Username
19
},
20
"customFields": { // Object User defined custom fields
21
"userDefinedField": "userValue", // User defined field example
22
"userDefinedField2": true, // User defined field example
23
"userObject3": { // User defined field example
24
"a": "hello",
25
"b": "lalala"
26
}
27
}
28
}
Copied!

Fields

Fields
Type
Description
_id
Random.id()
Subscriptions Id
t
String
Subscription Type (copy from Room)
ts
Date
Subscription Creation Timestamp
ls
Date
Last Seen Timestamp
name
String
Subscription Name (t:d -> target username)
rid
Random.id()
Room Id
f
Boolean
Favorited
open
Boolean
Is Room Opened
alert
Boolean
Room has unread messages for this user
unread
Integer
Counter of unread messages with mentions or from direct messages
u
Object
User
u._id
Random.id()
User Id
u.username
String
User Username
v
Object
Visitor
v._id
Random.id()
Visitor Id
v.username
String
Visitor Username
customFields
Object
User custom fields
Notes about customFields:
    customFields inherits from room's customFields for channels (Room Type: c = chanel) and groups (Room Type: p = group) and changes with room's customFields
    customFields inherits from user's customFields for Direct Messages (Room Type: d = direct) and changes with user's customFields. Note that users of Direct Messages room will have own customFields.

Indexes

Fields
Options
rid, u._id
unique
u._id, name, t
unique
open
alert
unread

Messages

1
{
2
"_id": "22nytdn4QqKvSk2Av", // Random.id()
3
"t": "p", // String Message Type
4
"ts": new Date(1432937851208), // Date Message Creation Timestamp
5
"rid": "25fkmHMDeFp57ZqYg", // Random.id() Room Id
6
"msg": "Yeah, doesn't seem to like it", // String Message Body
7
"url": [ // Array(String) Message URLs
8
"http://google.com/"
9
],
10
"expireAt": new Date(1432937951208), // Date Message auto-delete trigger
11
"mentions": [ // Array(String) Mentioned Usernames
12
"username1"
13
],
14
"u": { // Object User
15
"_id": "CABrXSHpDqbZXGkYR", // Random.id() User Id
16
"username": "john" // String User Username
17
},
18
"v": { // Object Visitor
19
"_id": "CABrXSHpDqbZXGkYR", // Random.id() Visitor Id
20
"username": "anonymous" // String Visitor Username
21
}
22
}
Copied!

Indexes

Fields
Options
rid, ts
expireAt
expireAfterSeconds

Visitors

1
{
2
"_id": "22nytdn4QqKvSk2Av", // Random.id()
3
"name": "John", // String Name
4
"email": "[email protected]", // String Email
5
"phone": "555 876333443", // String Phone
6
"token": "token" // String Token
7
}
Copied!

Indexes

Last modified 6mo ago