First: The bad news:
deepstream.io is purely a messaging server - it doesn't look into the data that passes through it. This means that any kind of querying functionality would need to be provided by another system, e.g. a client connected to RethinkDB.
Having said that: There's good news:
We're also looking into adding chat functionality (including extensive history keeping and searching) into our application.
Since chat messages are immutable (won't change once they are send) we will use deepstream events, rather than records. In order to facilitate chat history keeping, we’ll create a "chat history provider", a node process that sits between deepstream and our database and listens for any event that starts with 'chat-'
. (Assuming your chat events are named
chat-<chat-name>/<message-id>
, e.g. chat-idle-banter/254kbsdf-5mb2soodnv
)
On a very high level our chat-history-provider will look like this:
ds.event.listen( /chat-*/, function( chatName, messageData ) {
//Add the timestamp on the server-side, otherwise people
//can change the order of messages by changing their system clock
messageData.timestamp = Date.now();
rethinkdbConnector.set( chatName, messageData );
});
ds.rpc.provide( 'get-chat-history', function( data, response ){
//Query your database here
});
Currently deepstream only supports "listening" for records, but the upcoming version will offer the same kind of functionality for events and rpcs.