@@ -1000,6 +1000,10 @@ mongoc_collection_insert (mongoc_collection_t *collection,
1000
1000
1001
1001
bson_clear (& collection -> gle );
1002
1002
1003
+ if (!write_concern ) {
1004
+ write_concern = collection -> write_concern ;
1005
+ }
1006
+
1003
1007
if (!(flags & MONGOC_INSERT_NO_VALIDATE )) {
1004
1008
if (!bson_validate (document ,
1005
1009
(BSON_VALIDATE_UTF8 |
@@ -1217,44 +1221,38 @@ mongoc_collection_remove (mongoc_collection_t *collection,
1217
1221
const mongoc_write_concern_t * write_concern ,
1218
1222
bson_error_t * error )
1219
1223
{
1220
- uint32_t hint ;
1221
- mongoc_rpc_t rpc ;
1224
+ mongoc_write_command_t command ;
1225
+ mongoc_write_result_t result ;
1226
+ bool multi ;
1227
+ bool ret ;
1222
1228
1223
- bson_return_val_if_fail (collection , false);
1224
- bson_return_val_if_fail (selector , false);
1229
+ ENTRY ;
1230
+
1231
+ bson_return_val_if_fail (collection , false);
1232
+ bson_return_val_if_fail (selector , false);
1225
1233
1226
1234
bson_clear (& collection -> gle );
1227
1235
1228
1236
if (!write_concern ) {
1229
1237
write_concern = collection -> write_concern ;
1230
1238
}
1231
1239
1232
- if (!_mongoc_client_warm_up (collection -> client , error )) {
1233
- return false;
1234
- }
1240
+ multi = !(flags & MONGOC_REMOVE_SINGLE_REMOVE );
1235
1241
1236
- rpc .delete .msg_len = 0 ;
1237
- rpc .delete .request_id = 0 ;
1238
- rpc .delete .response_to = 0 ;
1239
- rpc .delete .opcode = MONGOC_OPCODE_DELETE ;
1240
- rpc .delete .zero = 0 ;
1241
- rpc .delete .collection = collection -> ns ;
1242
- rpc .delete .flags = flags ;
1243
- rpc .delete .selector = bson_get_data (selector );
1244
-
1245
- if (!(hint = _mongoc_client_sendv (collection -> client , & rpc , 1 , 0 ,
1246
- write_concern , NULL , error ))) {
1247
- return false;
1248
- }
1242
+ _mongoc_write_result_init (& result );
1243
+ _mongoc_write_command_init_delete (& command , selector , multi , true);
1249
1244
1250
- if (_mongoc_write_concern_has_gle (write_concern )) {
1251
- if (!_mongoc_client_recv_gle (collection -> client , hint ,
1252
- & collection -> gle , error )) {
1253
- return false;
1254
- }
1255
- }
1245
+ _mongoc_write_command_execute (& command , collection -> client , 0 ,
1246
+ collection -> db , collection -> collection ,
1247
+ write_concern , & result );
1256
1248
1257
- return true;
1249
+ collection -> gle = bson_new ();
1250
+ ret = _mongoc_write_result_complete (& result , collection -> gle , error );
1251
+
1252
+ _mongoc_write_result_destroy (& result );
1253
+ _mongoc_write_command_destroy (& command );
1254
+
1255
+ RETURN (ret );
1258
1256
}
1259
1257
1260
1258
0 commit comments