Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-1622

Comment on: "manual/tutorial/generate-test-data.txt"

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None

    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

      Attachments

        Activity

          People

            sam.kleinman Sam Kleinman (Inactive)
            auto auto
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              10 years, 35 weeks ago