Skip to content

Commit 6c607da

Browse files
author
Divjot Arora
committed
Change ListCollections filter to interface{}
GODRIVER-576 Change-Id: I25fc87f16ec29722c183b86b37663a2967615502
1 parent c545d10 commit 6c607da

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

mongo/database.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func (db *Database) Drop(ctx context.Context) error {
158158
}
159159

160160
// ListCollections list collections from mongodb database.
161-
func (db *Database) ListCollections(ctx context.Context, filter *bson.Document, opts ...*options.ListCollectionsOptions) (Cursor, error) {
161+
func (db *Database) ListCollections(ctx context.Context, filter interface{}, opts ...*options.ListCollectionsOptions) (Cursor, error) {
162162
if ctx == nil {
163163
ctx = context.Background()
164164
}
@@ -170,9 +170,17 @@ func (db *Database) ListCollections(ctx context.Context, filter *bson.Document,
170170
return nil, err
171171
}
172172

173+
var filterDoc *bson.Document
174+
if filter != nil {
175+
filterDoc, err = transformDocument(db.registry, filter)
176+
if err != nil {
177+
return nil, err
178+
}
179+
}
180+
173181
cmd := command.ListCollections{
174182
DB: db.name,
175-
Filter: filter,
183+
Filter: filterDoc,
176184
ReadPref: db.readPreference,
177185
Session: sess,
178186
Clock: db.client.clock,

0 commit comments

Comments
 (0)