我正在尝试实现这样的事情:
/* We use the command pattern to encode actions in
a 'command' object. This allows us to keep an audit trail
and is required to support 'undo' in the client app. */
CommandQueue.insert(command);
/* Queuing a command should trigger its execution. We use
an observer for this. */
CommandQueue
.find({...})
.observe({
added: function(command) {
/* While executing the action encoded by 'command'
we usually want to insert objects into other collections. */
OtherCollection.insert(...)
}
});
不幸的是,meteor 似乎保持了在OtherCollection
执行交易时的先前状态CommandQueue
。对OtherCollection
. 但是,一旦事务完成,就会恢复CommandQueue
先前的状态,并且我们的更改就会消失。OtherCollection
任何想法为什么会发生这种情况?这是预期的行为还是错误?