我正在使用 meteor-autoform
。我用
{{> quickForm collection="Messages" id="insertMessageForm" type="insert" fields="text"}}
它按原样插入消息,但我还想在 Notification 集合中创建一个文档。如何确保每次创建新消息时都会创建通知?每次在我的应用程序的集合中创建新文档时,我都想创建通知。如何做到这一点最聪明?我可以创建一个 afterCreate 信号或其他东西吗?
最佳答案
使用 meteor-core 功能 cursor.obsere
lib/
Messages.observe({
added: function (doc) {
Notifications.insert({ text: 'New Message: ' + doc.text })
}
})
doc
变量保存插入的新文档。
关于javascript - 使用 meteor-autoform 提交后创建文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31104543/