Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
访问MongoDB发行版的流星收藏?_Mongodb_Meteor - Fatal编程技术网

访问MongoDB发行版的流星收藏?

访问MongoDB发行版的流星收藏?,mongodb,meteor,Mongodb,Meteor,我已经使用Meteor创建并部署了一个应用程序。部署名称myapp.meteor.com。我已使用以下步骤连接到Mongo DB: 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

我已经使用Meteor创建并部署了一个应用程序。部署名称myapp.meteor.com。我已使用以下步骤连接到
Mongo DB

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.
Meteor的命令提示:

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代码创建了Emp集合。在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 : "abc@gmail.com"});

            }
  });


}
if(Meteor.isServer)
{
Meteor.startup(函数()
{;
if(Emp.find().count()==0)
{
对于(变量i=0;i<10;i++)
Emp.insert({fname:“xxx”,用户名:i,电子邮件:abc@gmail.com"});
}
});
}

您可能已经使用
Emp=new Meteor.Collection(“Emp”)
创建了集合(如果您这样做了)

问题是,只有在向集合中插入数据时,才会创建集合。如果按照上述方式创建集合,则只将其声明为变量,集合将不会出现在mongodb中


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

有时,在向集合写入内容时,实际上会创建集合。是的,但创建的集合如何从Mongo DB命令提示符中查看?@Akshat。与您的操作方式相同,您没有做错任何事情。您只是没有插入任何记录,因此不会有任何集合。是的,但它不会显示集合名称。@AkshatIs您提供的信息与您所做的完全一样吗?在您之前的问题中,您的问题通常与您的问题不匹配抱歉,我想不出任何其他原因可能是您遗漏了一些信息,或者您没有插入任何数据。