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

Add cursor.addOption() to reference section.

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • v1.2
    • None
    • None
    • None

    Description

      It's possible to add flags to mongoDB cursors to change the behavior of queries.

      These flags are documented in the wire protocol but are not documented as part of the cursor options.

      You can set these flags using the addOption() modifier, which is also not documented. Here's an example:

       
      ldb = db.getSiblingDB("local");
      c = ldb.oplog.rs.find( {ts: {$gte: Timestamp(1356412260000, 94) } } ).
              addOption( DBQuery.Option.tailable).
              addOption( DBQuery.Option.awaitData).
              addOption( DBQuery.Option.oplogReplay ) 
       
      var i = 0;
      while( c.hasNext() ) { 
          doc = c.next();
          printjson( doc);
      }
       

      Attachments

        Activity

          People

            kay.kim@mongodb.com Kay Kim (Inactive)
            william.zola@10gen.com William Zola
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              10 years, 44 weeks, 1 day ago