如何创建、更新变量 &如何在 Meteor 的 Mongo DB 中获取更新的变量? [英] How to create ,Update the variable & how to get Updated variable in Mongo DB in Meteor?

查看:50
本文介绍了如何创建、更新变量 &如何在 Meteor 的 Mongo DB 中获取更新的变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建、更新变量&如何在 Meteor 中的 Mongo DB 中获取更新的变量.以及如何将事件发送到 Mongo DB?我对此一无所知.所以请帮我怎么做.

How to create , Update the variable & how to get Updated variable in Mongo DB in Meteor. And also how to send event to Mongo DB? I didn't have any idea about that. so Please help me how to do.

推荐答案

只是为了让你开始:

YourData = new Meteor.Collection("yourdata");

// Create
YourData.insert({text: "Some text in this record"});

// Get
var record = YourData.findOne();
var receivedTextFromDatabase = record.text;
console.log("Text: " + receivedTextFromDatabase);

// Update
YourData.update({_id: record._id}, {$set: {text: "Changed this text"}});

然后,您必须在模板中声明使用此集合 (YourData).更新集合将自动更新您的模板和 html.文档实际上相当不错——请查看.

Then you'll have to declare the use of this collection (YourData) in your templates. Updating the collection will then automatically update your template and html. The documentation is actually pretty good—check it out.

这篇关于如何创建、更新变量 &如何在 Meteor 的 Mongo DB 中获取更新的变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆