blob: 5efb6e8f8fc8767f7ba5d1c3d8e3a3f962c926c6 [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// ListDatabasesOptions represents all possible options for a listDatabases command.
10type ListDatabasesOptions struct {
11 NameOnly *bool // If true, only the database names will be returned.
12}
13
14// ListDatabases creates a new *ListDatabasesOptions
15func ListDatabases() *ListDatabasesOptions {
16 return &ListDatabasesOptions{}
17}
18
19// SetNameOnly specifies whether to return only the database names.
20func (ld *ListDatabasesOptions) SetNameOnly(b bool) *ListDatabasesOptions {
21 ld.NameOnly = &b
22 return ld
23}
24
25// MergeListDatabasesOptions combines the given *ListDatabasesOptions into a single *ListDatabasesOptions in a last one
26// wins fashion.
27func MergeListDatabasesOptions(opts ...*ListDatabasesOptions) *ListDatabasesOptions {
28 ld := ListDatabases()
29 for _, opt := range opts {
30 if opts == nil {
31 continue
32 }
33 if opt.NameOnly != nil {
34 ld.NameOnly = opt.NameOnly
35 }
36 }
37
38 return ld
39}