0

试图了解 MongoDB,

此查询不会向 db 中插入任何内容:

> names = ['Serg', 'Bob', 'Sean', 'Sophia'];
[ "Serg", "Bob", "Sean", "Sophia" ]
> for (i=0; i<names.lenght; i++) db.people.insert({ name: names[i], age: Math.round(Math.random()*60) });
> db.people.find()
> 
4

1 回答 1

1

那是因为错字:lenght -> length

也许需要明确地创建集合,如db.createCollection('people');

于 2013-02-03T00:14:13.277 回答