Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-5708

Deprecate cursor returning command helpers

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 1.29.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • C Drivers
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Deprecate the following functions:

      • mongoc_client_command
      • mongoc_database_command
      • mongoc_collection_command

      Rationale

      Functions are already documented as "superseded by" other functions. There are multiple unused arguments. The returned cursors can only return a single document. There are other alternatives that do not return a cursor:

      mongoc_cursor_t *cursor = mongoc_client_command (client,
                                                        "admin",
                                                        MONGOC_QUERY_NONE /* unused */,
                                                        0 /* unused */,
                                                        0 /* unused */,
                                                        0 /* unused */,
                                                        ping,
                                                        NULL /* unused */,
                                                        NULL /* read prefs */);
      if (mongoc_cursor_next (cursor, &reply)) {
          char *as_json = bson_as_relaxed_extended_json (reply, NULL);
          printf ("got reply: %s\n", as_json);
          bson_free (as_json);
      }
      if (mongoc_cursor_error (cursor, &error)) {
          printf ("error: %s\n", error.message);
      }
      mongoc_cursor_destroy (cursor);
      

      Versus:

      bool ok = mongoc_client_command_simple (client, "admin", ping, NULL /* read prefs */, &reply, &error);
      if (!ok) {
          printf ("error: %s\n", error.message);
      }
      char *as_json = bson_as_relaxed_extended_json (&reply, NULL);
      printf ("got reply: %s\n", as_json);
      bson_free (as_json);
      

      Deprecating and future removal may enable removal of code within mongoc-cursor-cmd-deprecated.c.

            Assignee:
            kevin.albertson@mongodb.com Kevin Albertson
            Reporter:
            kevin.albertson@mongodb.com Kevin Albertson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: