【发布时间】:2016-03-29 23:39:38
【问题描述】:
我有两个集合:Commands 和 CommandHistory。我正在尝试制作一个接收它们两者结果的输出,结合起来,CommandHistory 中的任何内容都是粗体。也就是说,看起来像:
**Do the thing** <--| **Command History*
Doing thing <-|
thing is in progress <-| Commands
thing is done <-|
**Do the other thing** <-| **Command History**
I don't know what the other thing is <-| Commands
这是一个帮助器的基本开始:
log() {
const commandCursor = Commands.find({}, { sort: { timestamp: 1 } });
const commandHistory = CommandHistory.find({}, { sort: { timestamp: 1 } });
// what now? Need to concatenate them.
// `.fetch()` makes the interface seem non-reactive.
}
我唯一能真正想到的就是制作另一个 (null) 集合并将两个集合中的所有内容都输出到其中,这似乎有点矫枉过正。
是否可以连接这两个游标的结果,并且仍然让它反应?
【问题讨论】:
-
是否有将
Commands与CommandHistory相关联的密钥?看起来每个后者都有几个前者。 -
CommandHistory 会在他们提交表单并包含该表单的值时添加。提交成功后,通过 Meteor 方法运行命令
-
那么这两个集合之间有关键关系吗?
-
不是真的,一个看起来像
{ commands: 'MESSAGE "hello"', timestamp: ISODATE() },一个看起来像{ message: "Hello", timestamp: ISODATE }
标签: javascript meteor meteor-blaze minimongo