Uploaded image for project: 'C++ Driver'
  1. C++ Driver
  2. CXX-1490

Create Causal Consistency code samples for MongoDB 3.6 page

    • Type: Icon: Task Task
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Documentation
    • Labels:
      None

      Please provide the equivalent C++ code for the following example:

      Causal Consistency

      // 2. Tunable consistency controls
      String connectionString = "mongodb://localhost/?readPreference=secondaryPreferred";
       
      MongoClient client = new MongoClient(new MongoClientURI(connectionString);
       
      MongoDatabase database = client.getDatabase("myDatabase");
      MongoCollection<Document> collection = database.getCollection("myCollection");
       
      // Start client session, which is causally consistent by default
      try (ClientSession session = client.startSession(ClientSessionOptions.builder().build())) {
        //Run causally related operations within the session
        collection.insertOne(session, ...);
        collection.updateOne(session, ...);
       
        try (MongoCursor<Document> cursor = collection.find(session).filter(...).iterator()) {
          while (cursor.hasNext()) {
            Document cur = cursor.next();
          }
        }
      }
      

      DRIVERS Ticket Description
      Script Target - If you can read this text, the script has failed

            Assignee:
            Unassigned Unassigned
            Reporter:
            rathi.gnanasekaran Rathi Gnanasekaran
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: