blob: e44ad4a82fbe31ede5297d2ec674b3c7ee808ced [file] [log] [blame]
Don Newton379ae252019-04-01 12:17:06 -04001// Copyright (C) MongoDB, Inc. 2017-present.
2//
3// Licensed under the Apache License, Version 2.0 (the "License"); you may
4// not use this file except in compliance with the License. You may obtain
5// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
7package options
8
9// ListCollectionsOptions represents all possible options for a listCollections command.
10type ListCollectionsOptions struct {
11 NameOnly *bool // If true, only the collection names will be returned.
12}
13
14// ListCollections creates a new *ListCollectionsOptions
15func ListCollections() *ListCollectionsOptions {
16 return &ListCollectionsOptions{}
17}
18
19// SetNameOnly specifies whether to return only the collection names.
20func (lc *ListCollectionsOptions) SetNameOnly(b bool) *ListCollectionsOptions {
21 lc.NameOnly = &b
22 return lc
23}
24
25// MergeListCollectionsOptions combines the given *ListCollectionsOptions into a single *ListCollectionsOptions in a
26// last one wins fashion.
27func MergeListCollectionsOptions(opts ...*ListCollectionsOptions) *ListCollectionsOptions {
28 lc := ListCollections()
29 for _, opt := range opts {
30 if opt == nil {
31 continue
32 }
33 if opt.NameOnly != nil {
34 lc.NameOnly = opt.NameOnly
35 }
36 }
37
38 return lc
39}