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

mongoc_collection_find_and_modify_with_opts () builder

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.3.0-beta0
    • Component/s: libmongoc
    • Labels:
      None
    • Sprint:
      C Driver 2015Q2 sprint 9, C Driver 2015Q2 sprint 10

      Description

      We need a way to be able to extend the mongoc_collection_find_and_modify () helper for new options, for example bypassDocumentValidation.

                                                                                   
      typedef enum                                                                         
      {                                                                                    
         MONGOC_FIND_AND_MODIFY_NONE   = 0,                                                
         MONGOC_FIND_AND_MODIFY_REMOVE = 1 << 0,                                           
         MONGOC_FIND_AND_MODIFY_UPSERT = 1 << 1,                                           
         MONGOC_FIND_AND_MODIFY_RETURN_NEW = 1 << 2,                                       
      } mongoc_find_and_modify_flags_t;                                                    
                                                                                           
      typedef struct _mongoc_find_and_modify_opts_t mongoc_find_and_modify_opts_t ;        
      

                                                                                   
      mongoc_find_and_modify_opts_t* mongoc_find_and_modify_opts_new  (void);
      bool mongoc_find_and_modify_opts_set_sort                       (mongoc_find_and_modify_opts_t *opts, const bson_t                         *sort);
      bool mongoc_find_and_modify_opts_set_update                     (mongoc_find_and_modify_opts_t *opts, const bson_t                         *update);
      bool mongoc_find_and_modify_opts_set_fields                     (mongoc_find_and_modify_opts_t *opts, const bson_t                         *fields);
      bool mongoc_find_and_modify_opts_set_flags                      (mongoc_find_and_modify_opts_t *opts, const mongoc_find_and_modify_flags_t  flags);
      bool mongoc_find_and_modify_opts_set_bypass_document_validation (mongoc_find_and_modify_opts_t *opts,       bool                            bypass);
      void mongoc_find_and_modify_opts_destroy                        (mongoc_find_and_modify_opts_t *opts);
      

                                                                                   
      bool mongoc_collection_find_and_modify_with_opts (mongoc_collection_t                 *collection,
                                                        const bson_t                        *query,
                                                        const mongoc_find_and_modify_opts_t *opts,
                                                        bson_t                              *reply,
                                                        bson_error_t                        *error);
      

      Note that setting write_concern is not supported through the builder.
      Write concern must be set the collection level, which findAndModify will "inherit" and use when talking to MongoDB 3.2 and later.

      mongoc_collection_set_write_concern (collection, write_concern);
      mongoc_collection_find_and_modify_with_opts (collection, query, find_and_modify_opts, &reply, &error);
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              bjori Hannes Magnusson
              Reporter:
              matt.cotter Matt Cotter
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: