我将 LokiJs 用作应用程序的内存缓存,该应用程序将数据存储在 CouchDB 中并允许通过 NodeJS 服务器进行检索。根据有关构建查询的文档,我的查询结果被分配给一个结果集对象:
let result = combinedCache.find({'left.errorCode': errorCode});
此combinedCache
集合是.eqJoin
其他两个集合的结果:
var cache = new loki('loki.db');
errorCodeCache = cache.addCollection('errorCodes');
messageCache = cache.addCollection('messages');
errorCodeCache.insert(docs.errorCodes);
messageCache.insert(docs.messages);
combinedCache = errorCodeCache.eqJoin(
messageCache,
'messageId',
'_id'
);
这将创建两个集合,一个errorCodeCache
集合和一个messageCache
集合。这combinedCache
是错误messageId
代码文档和_id
消息文档的连接结果。当combinedCache
我使用combinedCache.data().length
.
但是,在我对缓存执行查询后,原始集合的大小更改为结果的大小;换句话说,如果我的查询返回 1 个 CouchDB 文档,combinedCache
则 的大小现在为 1。我在文档中找不到任何引用说明.find
对集合的查询会改变集合本身的结果。如果是这种情况,如何保留集合的大小?谢谢!