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

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

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Environment:
    • # Replies:
      0
    • Last comment by Customer:
      true

      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

            • Assignee:
              sam.kleinman Sam Kleinman
              Reporter:
              auto auto
              Participants:
              Last commenter:
              Jonathan Dahl
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since reply:
                6 years, 9 weeks, 6 days ago
                Date of 1st Reply: