用meteorautoform提交后创build文档
我正在使用meteor-autoform
。 我创build我的表单
{{> quickForm collection="Messages" id="insertMessageForm" type="insert" fields="text"}}
它插入消息,因为它应该但我也想在通知集合中创build一个文档。 如何确保每次创build新消息时都会创build通知? 我想创build通知每次在我的应用程序集合中创build一个新的文档。 这怎么能做到最聪明呢? 我可以创build一个afterCreate信号或什么?
使用meteor-corefunctioncursor.obsere
lib/
Messages.observe({ added: function (doc) { Notifications.insert({ text: 'New Message: ' + doc.text }) } })
doc
variables保存插入的新文档。
我想创build通知每次在我的应用程序集合中创build一个新的文档。
那么你应该使用这个包: matb33:collection-hooks
您将能够为每个集合创build钩子,以在插入新文档时创build通知。
Comments.after.insert(function(userId, comment){ Notifications.insert({ userId: userId, text: comment.text, createdAt: comment.createdAt }); });
使用这个包时要小心,不要过于复杂的应用程序逻辑和创build圆形钩子。
- 在每个请求上最好有一个从节点或连接到memcached / mongo的全局连接?
- 无法得到globalShortcut注册命令index.js使用发送函数在节点/电子JavaScript应用程序
- 奇怪的TypeError在Node.js
- 接受或抵制Node缺乏types安全的问题
- Uncaught TypeError在ES6中使用React Router呈现<Router>:type.toUpperCase不是函数
- 新的实例与标准函数内存使用socket.io事件
- Promise.all当它从.then()callback返回时不工作
- Node.js + Nativefier应用程序不会下载文件
- 迭代数组并等待promise