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

Comment on: "primer/aggregation.txt"

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Major - P3 Major - P3
    • 01112017-cleanup
    • None
    • None

    Description

      Hello, (https://docs.mongodb.org/getting-started/python/aggregation/)

      Your documentation is not complete.

      The "db.collection.aggregate.(....)" will not return a cursor on the different value but a dict with "ok" (with value 0 or 1) and "result" (with the different values).

      The actual documentation should be:

      ----------------------------------------------------------------------------------------

      cursor = db.restaurants.aggregate(
      [
      {"$group": {"_id": "$borough", "count":

      {"$sum": 1}

      }}
      ]
      )

      if cursor['ok'] == 1:
      for document in cursor['result']:
      print(document)
      else:
      print "No document found"

      ----------------------------------------------------------------------------------------

      Hope it will be useful.

      Thanks you.

      Attachments

        Activity

          People

            kay.kim@mongodb.com Kay Kim (Inactive)
            xgen-internal-docs Docs Collector User (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              7 years, 46 weeks, 2 days ago