与 deepstream.io 记录服务器端交互

Interacting with deepstream.io records server side

我一直在阅读 deepstream.io,到目前为止我发现了以下内容:

  1. 所有记录都存储在同一个table(默认deepstream_records

  2. 要与此数据交互,可以使用客户端,包括客户端(浏览器)和服务器端(节点),但是应该 在服务器端(节点)使用。

问题:

来自 RethinkDB 的数据示例:
{
  "_d": { },
  "_v": 0,
  "ds_id":  "users/"
}, {
  "_d": { },
  "_v": 0,
  "ds_id":  "users/admin"
}

为什么所有记录都存储在同一个table?

server.set( 'storage', new RethinkDBStorageConnector( { 
  port: 5672, 
  host: 'localhost' ,
    /* (Optional) A character that's used as part of the
    * record names to split it into a tabel and an id part, e.g.
    * 
    * books/dream-of-the-red-chamber
    *
    * would create a table called 'books' and store the record under the name
    * 'dream-of-the-red-chamber'
    */
  splitChar: '/'
}));

server.start();

你没提splitChar吗? (它不是默认值)

我应该如何与服务器端的记录进行交互?

要与此数据交互,您将创建一个使用 tcp(默认端口 6021)连接到您的服务器的节点客户端。服务器本身是一个非常高效的消息代理,可以以低延迟分发消息,我们的建议是不要包含任何不必要的自定义代码,即使在使用许可和数据转换时也是如此。 https://deepstream.io/tutorials/core/transforming-data

您可以在教程的 FX 提供商示例中看到这一点:

https://deepstream.io/tutorials/core/active-data-providers

以及坦克游戏教程示例:

https://github.com/deepstreamIO/ds-tutorial-tanks

有什么东西阻止我更改数据库中的记录吗?

deepstream 通过实际对缓存执行所有 writes/reads 来保持其低延迟。写入数据库是次要的,以免造成命中。因此,直接更改记录实际上不会通知任何用户,也不会破坏用于合并处理的一些逻辑...