[DOCS-1622] Comment on: "manual/tutorial/generate-test-data.txt" Created: 19/Jun/13  Updated: 03/Nov/17  Resolved: 19/Jun/13

Status: Closed
Project: Documentation
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: auto Assignee: Sam Kleinman (Inactive)
Resolution: Done Votes: 0
Labels: collector-298ba4e7
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
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


Participants:
Days since reply: 10 years, 35 weeks ago

 Description   

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(

{x:i}

);
}

print(col.count());

}

Thanks ans congratulations for your work.
Regards


Generated at Thu Feb 08 07:41:29 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.