@@ -39,7 +39,7 @@ use crate::{
39
39
/// ```rust
40
40
///
41
41
/// # #[cfg(not(feature = "sync"))]
42
- /// # use mongodb::{Client, error::Result};
42
+ /// # use mongodb::{bson::Document, Client, error::Result};
43
43
/// # #[cfg(feature = "async-std-runtime")]
44
44
/// # use async_std::task;
45
45
/// # #[cfg(feature = "tokio-runtime")]
@@ -55,7 +55,7 @@ use crate::{
55
55
/// let db_ref = db.clone();
56
56
///
57
57
/// task::spawn(async move {
58
- /// let collection = db_ref.collection(&format!("coll{}", i));
58
+ /// let collection = db_ref.collection::<Document> (&format!("coll{}", i));
59
59
///
60
60
/// // Do something with the collection
61
61
/// });
@@ -129,45 +129,26 @@ impl Database {
129
129
self . inner . write_concern . as_ref ( )
130
130
}
131
131
132
- /// Gets a handle to a collection specified by `name` of the database. The `Collection` options
133
- /// (e.g. read preference and write concern) will default to those of the `Database`.
134
- ///
135
- /// This method does not send or receive anything across the wire to the database, so it can be
136
- /// used repeatedly without incurring any costs from I/O.
137
- pub fn collection ( & self , name : & str ) -> Collection {
138
- Collection :: new ( self . clone ( ) , name, None )
139
- }
140
-
141
132
/// Gets a handle to a collection with type `T` specified by `name` of the database. The
142
133
/// `Collection` options (e.g. read preference and write concern) will default to those of the
143
134
/// `Database`.
144
135
///
145
136
/// This method does not send or receive anything across the wire to the database, so it can be
146
137
/// used repeatedly without incurring any costs from I/O.
147
- pub fn collection_with_type < T > ( & self , name : & str ) -> Collection < T >
138
+ pub fn collection < T > ( & self , name : & str ) -> Collection < T >
148
139
where
149
140
T : Serialize + DeserializeOwned + Unpin + Debug ,
150
141
{
151
142
Collection :: new ( self . clone ( ) , name, None )
152
143
}
153
144
154
- /// Gets a handle to a collection specified by `name` in the cluster the `Client` is connected
155
- /// to. Operations done with this `Collection` will use the options specified by `options` by
156
- /// default and will otherwise default to those of the `Database`.
157
- ///
158
- /// This method does not send or receive anything across the wire to the database, so it can be
159
- /// used repeatedly without incurring any costs from I/O.
160
- pub fn collection_with_options ( & self , name : & str , options : CollectionOptions ) -> Collection {
161
- Collection :: new ( self . clone ( ) , name, Some ( options) )
162
- }
163
-
164
145
/// Gets a handle to a collection with type `T` specified by `name` in the cluster the `Client`
165
146
/// is connected to. Operations done with this `Collection` will use the options specified by
166
147
/// `options` by default and will otherwise default to those of the `Database`.
167
148
///
168
149
/// This method does not send or receive anything across the wire to the database, so it can be
169
150
/// used repeatedly without incurring any costs from I/O.
170
- pub fn collection_with_type_and_options < T > (
151
+ pub fn collection_with_options < T > (
171
152
& self ,
172
153
name : & str ,
173
154
options : CollectionOptions ,
@@ -213,7 +194,7 @@ impl Database {
213
194
& self ,
214
195
filter : impl Into < Option < Document > > ,
215
196
options : impl Into < Option < ListCollectionsOptions > > ,
216
- ) -> Result < Cursor > {
197
+ ) -> Result < Cursor < Document > > {
217
198
let list_collections = ListCollections :: new (
218
199
self . name ( ) . to_string ( ) ,
219
200
filter. into ( ) ,
@@ -234,7 +215,7 @@ impl Database {
234
215
filter : impl Into < Option < Document > > ,
235
216
options : impl Into < Option < ListCollectionsOptions > > ,
236
217
session : & mut ClientSession ,
237
- ) -> Result < SessionCursor > {
218
+ ) -> Result < SessionCursor < Document > > {
238
219
let list_collections = ListCollections :: new (
239
220
self . name ( ) . to_string ( ) ,
240
221
filter. into ( ) ,
@@ -392,7 +373,7 @@ impl Database {
392
373
& self ,
393
374
pipeline : impl IntoIterator < Item = Document > ,
394
375
options : impl Into < Option < AggregateOptions > > ,
395
- ) -> Result < Cursor > {
376
+ ) -> Result < Cursor < Document > > {
396
377
let mut options = options. into ( ) ;
397
378
resolve_options ! (
398
379
self ,
@@ -417,7 +398,7 @@ impl Database {
417
398
pipeline : impl IntoIterator < Item = Document > ,
418
399
options : impl Into < Option < AggregateOptions > > ,
419
400
session : & mut ClientSession ,
420
- ) -> Result < SessionCursor > {
401
+ ) -> Result < SessionCursor < Document > > {
421
402
let mut options = options. into ( ) ;
422
403
resolve_options ! (
423
404
self ,
0 commit comments