@@ -93,12 +93,12 @@ impl Collection {
93
93
94
94
let mut spec = bson:: Document :: new ( ) ;
95
95
let mut cursor = bson:: Document :: new ( ) ;
96
- cursor. insert ( "batchSize" . to_owned ( ) , Bson :: I32 ( opts. batch_size ) ) ;
97
- spec. insert ( "aggregate" . to_owned ( ) , Bson :: String ( self . name ( ) ) ) ;
98
- spec. insert ( "pipeline" . to_owned ( ) , Bson :: Array ( pipeline_map) ) ;
99
- spec. insert ( "cursor" . to_owned ( ) , Bson :: Document ( cursor) ) ;
96
+ cursor. insert ( "batchSize" , Bson :: I32 ( opts. batch_size ) ) ;
97
+ spec. insert ( "aggregate" , Bson :: String ( self . name ( ) ) ) ;
98
+ spec. insert ( "pipeline" , Bson :: Array ( pipeline_map) ) ;
99
+ spec. insert ( "cursor" , Bson :: Document ( cursor) ) ;
100
100
if opts. allow_disk_use {
101
- spec. insert ( "allowDiskUse" . to_owned ( ) , Bson :: Boolean ( opts. allow_disk_use ) ) ;
101
+ spec. insert ( "allowDiskUse" , Bson :: Boolean ( opts. allow_disk_use ) ) ;
102
102
}
103
103
104
104
let read_pref = opts. read_preference . unwrap_or ( self . read_preference . to_owned ( ) ) ;
@@ -111,18 +111,18 @@ impl Collection {
111
111
let opts = options. unwrap_or ( CountOptions :: new ( ) ) ;
112
112
113
113
let mut spec = bson:: Document :: new ( ) ;
114
- spec. insert ( "count" . to_owned ( ) , Bson :: String ( self . name ( ) ) ) ;
115
- spec. insert ( "skip" . to_owned ( ) , Bson :: I64 ( opts. skip as i64 ) ) ;
116
- spec. insert ( "limit" . to_owned ( ) , Bson :: I64 ( opts. limit ) ) ;
114
+ spec. insert ( "count" , Bson :: String ( self . name ( ) ) ) ;
115
+ spec. insert ( "skip" , Bson :: I64 ( opts. skip as i64 ) ) ;
116
+ spec. insert ( "limit" , Bson :: I64 ( opts. limit ) ) ;
117
117
if filter. is_some ( ) {
118
- spec. insert ( "query" . to_owned ( ) , Bson :: Document ( filter. unwrap ( ) ) ) ;
118
+ spec. insert ( "query" , Bson :: Document ( filter. unwrap ( ) ) ) ;
119
119
}
120
120
121
121
// Favor specified hint document over string
122
122
if opts. hint_doc . is_some ( ) {
123
- spec. insert ( "hint" . to_owned ( ) , Bson :: Document ( opts. hint_doc . unwrap ( ) ) ) ;
123
+ spec. insert ( "hint" , Bson :: Document ( opts. hint_doc . unwrap ( ) ) ) ;
124
124
} else if opts. hint . is_some ( ) {
125
- spec. insert ( "hint" . to_owned ( ) , Bson :: String ( opts. hint . unwrap ( ) ) ) ;
125
+ spec. insert ( "hint" , Bson :: String ( opts. hint . unwrap ( ) ) ) ;
126
126
}
127
127
128
128
let read_pref = opts. read_preference . unwrap_or ( self . read_preference . to_owned ( ) ) ;
@@ -141,10 +141,10 @@ impl Collection {
141
141
let opts = options. unwrap_or ( DistinctOptions :: new ( ) ) ;
142
142
143
143
let mut spec = bson:: Document :: new ( ) ;
144
- spec. insert ( "distinct" . to_owned ( ) , Bson :: String ( self . name ( ) ) ) ;
145
- spec. insert ( "key" . to_owned ( ) , Bson :: String ( field_name. to_owned ( ) ) ) ;
144
+ spec. insert ( "distinct" , Bson :: String ( self . name ( ) ) ) ;
145
+ spec. insert ( "key" , Bson :: String ( field_name. to_owned ( ) ) ) ;
146
146
if filter. is_some ( ) {
147
- spec. insert ( "query" . to_owned ( ) , Bson :: Document ( filter. unwrap ( ) ) ) ;
147
+ spec. insert ( "query" , Bson :: Document ( filter. unwrap ( ) ) ) ;
148
148
}
149
149
150
150
let read_pref = opts. read_preference . unwrap_or ( self . read_preference . to_owned ( ) ) ;
@@ -217,14 +217,14 @@ impl Collection {
217
217
let wc = write_concern. unwrap_or ( self . write_concern . clone ( ) ) ;
218
218
219
219
let mut new_cmd = bson:: Document :: new ( ) ;
220
- new_cmd. insert ( "findAndModify" . to_owned ( ) , Bson :: String ( self . name ( ) ) ) ;
221
- new_cmd. insert ( "query" . to_owned ( ) , Bson :: Document ( filter) ) ;
222
- new_cmd. insert ( "writeConcern" . to_owned ( ) , Bson :: Document ( wc. to_bson ( ) ) ) ;
220
+ new_cmd. insert ( "findAndModify" , Bson :: String ( self . name ( ) ) ) ;
221
+ new_cmd. insert ( "query" , Bson :: Document ( filter) ) ;
222
+ new_cmd. insert ( "writeConcern" , Bson :: Document ( wc. to_bson ( ) ) ) ;
223
223
if sort. is_some ( ) {
224
- new_cmd. insert ( "sort" . to_owned ( ) , Bson :: Document ( sort. unwrap ( ) ) ) ;
224
+ new_cmd. insert ( "sort" , Bson :: Document ( sort. unwrap ( ) ) ) ;
225
225
}
226
226
if projection. is_some ( ) {
227
- new_cmd. insert ( "fields" . to_owned ( ) , Bson :: Document ( projection. unwrap ( ) ) ) ;
227
+ new_cmd. insert ( "fields" , Bson :: Document ( projection. unwrap ( ) ) ) ;
228
228
}
229
229
230
230
for ( key, val) in cmd. iter ( ) {
@@ -249,12 +249,12 @@ impl Collection {
249
249
Option < WriteConcern > , cmd_type : CommandType ) -> Result < Option < bson:: Document > > {
250
250
251
251
let mut cmd = bson:: Document :: new ( ) ;
252
- cmd. insert ( "update" . to_owned ( ) , Bson :: Document ( update) ) ;
252
+ cmd. insert ( "update" , Bson :: Document ( update) ) ;
253
253
if after {
254
- cmd. insert ( "new" . to_owned ( ) , Bson :: Boolean ( true ) ) ;
254
+ cmd. insert ( "new" , Bson :: Boolean ( true ) ) ;
255
255
}
256
256
if upsert {
257
- cmd. insert ( "upsert" . to_owned ( ) , Bson :: Boolean ( true ) ) ;
257
+ cmd. insert ( "upsert" , Bson :: Boolean ( true ) ) ;
258
258
}
259
259
260
260
self . find_and_modify ( & mut cmd, filter, max_time_ms, projection, sort, write_concern,
@@ -267,7 +267,7 @@ impl Collection {
267
267
268
268
let opts = options. unwrap_or ( FindOneAndDeleteOptions :: new ( ) ) ;
269
269
let mut cmd = bson:: Document :: new ( ) ;
270
- cmd. insert ( "remove" . to_owned ( ) , Bson :: Boolean ( true ) ) ;
270
+ cmd. insert ( "remove" , Bson :: Boolean ( true ) ) ;
271
271
self . find_and_modify ( & mut cmd, filter, opts. max_time_ms ,
272
272
opts. projection , opts. sort , opts. write_concern ,
273
273
CommandType :: FindOneAndDelete )
@@ -483,18 +483,18 @@ impl Collection {
483
483
Some ( id) => ids. push ( id. clone ( ) ) ,
484
484
None => {
485
485
let id = Bson :: ObjectId ( try!( oid:: ObjectId :: new ( ) ) ) ;
486
- cdoc. insert ( "_id" . to_owned ( ) , id. clone ( ) ) ;
486
+ cdoc. insert ( "_id" , id. clone ( ) ) ;
487
487
ids. push ( id) ;
488
488
}
489
489
}
490
490
converted_docs. push ( Bson :: Document ( cdoc) ) ;
491
491
}
492
492
493
493
let mut cmd = bson:: Document :: new ( ) ;
494
- cmd. insert ( "insert" . to_owned ( ) , Bson :: String ( self . name ( ) ) ) ;
495
- cmd. insert ( "documents" . to_owned ( ) , Bson :: Array ( converted_docs) ) ;
496
- cmd. insert ( "ordered" . to_owned ( ) , Bson :: Boolean ( ordered) ) ;
497
- cmd. insert ( "writeConcern" . to_owned ( ) , Bson :: Document ( wc. to_bson ( ) ) ) ;
494
+ cmd. insert ( "insert" , Bson :: String ( self . name ( ) ) ) ;
495
+ cmd. insert ( "documents" , Bson :: Array ( converted_docs) ) ;
496
+ cmd. insert ( "ordered" , Bson :: Boolean ( ordered) ) ;
497
+ cmd. insert ( "writeConcern" , Bson :: Document ( wc. to_bson ( ) ) ) ;
498
498
499
499
let result = try!( self . db . command ( cmd, cmd_type, None ) ) ;
500
500
@@ -568,19 +568,19 @@ impl Collection {
568
568
let mut deletes = Vec :: new ( ) ;
569
569
for model in models {
570
570
let mut delete = bson:: Document :: new ( ) ;
571
- delete. insert ( "q" . to_owned ( ) , Bson :: Document ( model. filter ) ) ;
571
+ delete. insert ( "q" , Bson :: Document ( model. filter ) ) ;
572
572
let limit = if model. multi { 0 } else { 1 } ;
573
- delete. insert ( "limit" . to_owned ( ) , Bson :: I64 ( limit) ) ;
573
+ delete. insert ( "limit" , Bson :: I64 ( limit) ) ;
574
574
deletes. push ( Bson :: Document ( delete) ) ;
575
575
}
576
576
577
577
let mut cmd = bson:: Document :: new ( ) ;
578
- cmd. insert ( "delete" . to_owned ( ) , Bson :: String ( self . name ( ) ) ) ;
579
- cmd. insert ( "deletes" . to_owned ( ) , Bson :: Array ( deletes) ) ;
578
+ cmd. insert ( "delete" , Bson :: String ( self . name ( ) ) ) ;
579
+ cmd. insert ( "deletes" , Bson :: Array ( deletes) ) ;
580
580
if !ordered {
581
- cmd. insert ( "ordered" . to_owned ( ) , Bson :: Boolean ( ordered) ) ;
581
+ cmd. insert ( "ordered" , Bson :: Boolean ( ordered) ) ;
582
582
}
583
- cmd. insert ( "writeConcern" . to_owned ( ) , Bson :: Document ( wc. to_bson ( ) ) ) ;
583
+ cmd. insert ( "writeConcern" , Bson :: Document ( wc. to_bson ( ) ) ) ;
584
584
585
585
let result = try!( self . db . command ( cmd, cmd_type, None ) ) ;
586
586
@@ -631,22 +631,22 @@ impl Collection {
631
631
let mut updates = Vec :: new ( ) ;
632
632
for model in models {
633
633
let mut update = bson:: Document :: new ( ) ;
634
- update. insert ( "q" . to_owned ( ) , Bson :: Document ( model. filter ) ) ;
635
- update. insert ( "u" . to_owned ( ) , Bson :: Document ( model. update ) ) ;
636
- update. insert ( "upsert" . to_owned ( ) , Bson :: Boolean ( model. upsert ) ) ;
634
+ update. insert ( "q" , Bson :: Document ( model. filter ) ) ;
635
+ update. insert ( "u" , Bson :: Document ( model. update ) ) ;
636
+ update. insert ( "upsert" , Bson :: Boolean ( model. upsert ) ) ;
637
637
if !ordered {
638
- update. insert ( "ordered" . to_owned ( ) , Bson :: Boolean ( ordered) ) ;
638
+ update. insert ( "ordered" , Bson :: Boolean ( ordered) ) ;
639
639
}
640
640
if model. multi {
641
- update. insert ( "multi" . to_owned ( ) , Bson :: Boolean ( model. multi ) ) ;
641
+ update. insert ( "multi" , Bson :: Boolean ( model. multi ) ) ;
642
642
}
643
643
updates. push ( Bson :: Document ( update) ) ;
644
644
}
645
645
646
646
let mut cmd = bson:: Document :: new ( ) ;
647
- cmd. insert ( "update" . to_owned ( ) , Bson :: String ( self . name ( ) ) ) ;
648
- cmd. insert ( "updates" . to_owned ( ) , Bson :: Array ( updates) ) ;
649
- cmd. insert ( "writeConcern" . to_owned ( ) , Bson :: Document ( wc. to_bson ( ) ) ) ;
647
+ cmd. insert ( "update" , Bson :: String ( self . name ( ) ) ) ;
648
+ cmd. insert ( "updates" , Bson :: Array ( updates) ) ;
649
+ cmd. insert ( "writeConcern" , Bson :: Document ( wc. to_bson ( ) ) ) ;
650
650
651
651
let result = try!( self . db . command ( cmd, cmd_type, None ) ) ;
652
652
@@ -741,8 +741,8 @@ impl Collection {
741
741
}
742
742
743
743
let mut cmd = bson:: Document :: new ( ) ;
744
- cmd. insert ( "createIndexes" . to_owned ( ) , Bson :: String ( self . name ( ) ) ) ;
745
- cmd. insert ( "indexes" . to_owned ( ) , Bson :: Array ( indexes) ) ;
744
+ cmd. insert ( "createIndexes" , Bson :: String ( self . name ( ) ) ) ;
745
+ cmd. insert ( "indexes" , Bson :: Array ( indexes) ) ;
746
746
let result = try!( self . db . command ( cmd, CommandType :: CreateIndexes , None ) ) ;
747
747
748
748
match result. get ( "errmsg" ) {
@@ -769,8 +769,8 @@ impl Collection {
769
769
/// Drop an index by IndexModel.
770
770
pub fn drop_index_model ( & self , model : IndexModel ) -> Result < ( ) > {
771
771
let mut cmd = bson:: Document :: new ( ) ;
772
- cmd. insert ( "dropIndexes" . to_owned ( ) , Bson :: String ( self . name ( ) ) ) ;
773
- cmd. insert ( "index" . to_owned ( ) , Bson :: String ( try!( model. name ( ) ) ) ) ;
772
+ cmd. insert ( "dropIndexes" , Bson :: String ( self . name ( ) ) ) ;
773
+ cmd. insert ( "index" , Bson :: String ( try!( model. name ( ) ) ) ) ;
774
774
775
775
let result = try!( self . db . command ( cmd, CommandType :: DropIndexes , None ) ) ;
776
776
match result. get ( "errmsg" ) {
@@ -791,7 +791,7 @@ impl Collection {
791
791
/// List all indexes in the collection.
792
792
pub fn list_indexes ( & self ) -> Result < Cursor > {
793
793
let mut cmd = bson:: Document :: new ( ) ;
794
- cmd. insert ( "listIndexes" . to_owned ( ) , Bson :: String ( self . name ( ) ) ) ;
794
+ cmd. insert ( "listIndexes" , Bson :: String ( self . name ( ) ) ) ;
795
795
self . db . command_cursor ( cmd, CommandType :: ListIndexes , self . read_preference . to_owned ( ) )
796
796
}
797
797
}
0 commit comments