File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -136,6 +136,11 @@ func (coll *Collection) namespace() command.Namespace {
136
136
return command .NewNamespace (coll .db .name , coll .name )
137
137
}
138
138
139
+ // Database provides access to the database that contains the collection.
140
+ func (coll * Collection ) Database () * Database {
141
+ return coll .db
142
+ }
143
+
139
144
// InsertOne inserts a single document into the collection. A user can supply
140
145
// a custom context to this method, or nil to default to context.Background().
141
146
//
Original file line number Diff line number Diff line change @@ -174,6 +174,16 @@ func TestCollection_name_accessor(t *testing.T) {
174
174
175
175
}
176
176
177
+ func TestCollection_database_accessor (t * testing.T ) {
178
+ t .Parallel ()
179
+
180
+ dbName := "foo"
181
+ collName := "bar"
182
+
183
+ coll := createTestCollection (t , & dbName , & collName )
184
+ require .Equal (t , coll .Database ().Name (), dbName )
185
+ }
186
+
177
187
func TestCollection_InsertOne (t * testing.T ) {
178
188
if testing .Short () {
179
189
t .Skip ("skipping integration test in short mode" )
You can’t perform that action at this time.
0 commit comments