2014-02-17 26 views
1

我创建了&使用Meteor部署了一个应用程序。部署名称myapp.meteor.com访问来自MongoDB的Meteor Collections问题?

命令提示符从流星:

Meteor mongo myapp.meteor.com 

//Below one is Response from Meteor mongo myapp.meteor.com command 

MongoDB shell version: 2.4.8 
connecting to: production-db-b3.meteor.io:27017/myapp_meteor_com 

命令提示符从MongoDB的:

use myapp_meteor_com 

我一直在使用的myapp code.From创建的Emp收集我曾尝试使用以下程序连接到Mongo DB Mongo DB命令提示符我将尝试从myapp中看到创建的集合但它不显示。并且我正在使用以下过程显示集合:

connecting to: test 
> show dbs 
myapp_meteor_com  (empty) 
local 0.078125GB 
> use myapp_meteor_com 
switched to db myapp_meteor_com 
> show collections //here shows nothing but js file contains `Emp Collection` and data inserted as shown below. 
>      //here no collections shows. 

所以我没有任何想法显示,请建议我为上述问题做什么?

//将这里的数据插入Emp集合obj。 JS代码:

if (Meteor.isServer) 
{ 
    Meteor.startup(function() 
    {; 

      if (Emp.find().count() === 0) 
      { 
       for (var i = 0; i < 10; i++) 
       Emp.insert({ fname: "xxx",userid: i, email : "[email protected]"}); 

      } 
    }); 


} 
+0

有时集合实际上是在您为其写入内容时创建的。 – imslavko

回答

0

你可能已经使用Emp = new Meteor.Collection("emp")(如果你这样做)创建的集合。

问题是只有在向他们插入数据时才会创建集合。如果以上述方式创建集合,则只会将其声明为变量,并且集合不会显示在mongodb中。

这通常是mongodb的工作原理:集合是在向其中插入数据时自动创建的。

+0

是的,但创建的集合如何从Mongo DB命令提示符中看到?。@ Akshat。 – Venkat

+0

就像你在做的一样,你在那里没有做错任何事。你刚刚没有插入任何记录,所以你不会有任何收藏。 – Akshat

+0

是的,但它没有显示集合名称。@ Akshat – Venkat