-
Type: Improvement
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Labels:
-
Environment:Ubuntu 12.04
*Location*: http://docs.mongodb.org/manual/tutorial/generate-test-data/
*User-Agent*: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:21.0) Gecko/20100101 Firefox/21.0
*Referrer*: http://docs.mongodb.org/manual/tutorial/getting-started/
*Screen Resolution*: 1280 x 800
*repo*: docs
*source*: tutorial/generate-test-data
Ubuntu 12.04 *Location*: http://docs.mongodb.org/manual/tutorial/generate-test-data/ *User-Agent*: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:21.0) Gecko/20100101 Firefox/21.0 *Referrer*: http://docs.mongodb.org/manual/tutorial/getting-started/ *Screen Resolution*: 1280 x 800 *repo*: docs *source*: tutorial/generate-test-data
Hi there!
I have problems with the javascript function to create data for testing.
I copy and paste this function on the .mongorc.js file but when I am using this function in the shell console an error appears:
"TypeError: Cannot call method 'getSiblingDB' of undefined at /home/user/.mongorc.js:L3"
I think the problem is using the var name "db" because is a keyword.
I change this function renaming this var to "database" and now is working.
function insertData(dbName, colName, num) {
var database = db.getSiblingDB(dbName);
var col = database.getCollection(colName);
for (i = 0; i < num; i++) {
col.insert(
);
}
print(col.count());
}
Thanks ans congratulations for your work.
Regards