官术网_书友最值得收藏!

Explore MongoDB in the Meteor shell

You can access all the application data with the Meteor MongoDB shell.

Open another terminal, cd to the app directory, and start the MongoDB shell.

The app should be running at the same time.
>> meteor mongo

Show all the databases in MongoDB:

>> show dbs

The default database for the app is named meteor; switch to the meteor database:

>> use meteor

Display all collections in the database:

>>show collections

The show collections command will not return any results.

The reason is that we created a collection on the client side only. This collection exists in Minimongo, and it is in the browser's memory. If we refresh the page, the collection and the data will be gone.

In order to create the same collection and persist data into MongoDB, we have to execute the exact same Time = new Mongo.Collection('time'); on the server. As soon as we do that, both the collections will be in sync and the data will be persisted into the database.

For now, we don't want to save the timer data on the server; we only want to take advantage of the Meteor server to client real-time communication.

主站蜘蛛池模板: 于田县| 白朗县| 嘉祥县| 乌苏市| 云龙县| 日土县| 信阳市| 襄樊市| 射阳县| 石城县| 连云港市| 吴桥县| 松滋市| 康平县| 屯昌县| 湖州市| 综艺| 饶阳县| 德惠市| 宁乡县| 临泽县| 西城区| 三都| 山阴县| 五家渠市| 开封市| 玉山县| 卓尼县| 蓝山县| 阜城县| 桂东县| 抚顺市| 弥勒县| 尚志市| 喜德县| 玉龙| 清流县| 周至县| 榆树市| 土默特左旗| 威远县|