github.com/mdaxf/iac@v0.0.0-20240519030858-58a061660378/vendor_skip/go.mongodb.org/mongo-driver/mongo/options/listdatabasesoptions.go (about)

     1  // 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  
     7  package options
     8  
     9  // ListDatabasesOptions represents options that can be used to configure a ListDatabases operation.
    10  type ListDatabasesOptions struct {
    11  	// If true, only the Name field of the returned DatabaseSpecification objects will be populated. The default value
    12  	// is false.
    13  	NameOnly *bool
    14  
    15  	// If true, only the databases which the user is authorized to see will be returned. For more information about
    16  	// the behavior of this option, see https://www.mongodb.com/docs/manual/reference/privilege-actions/#find. The default
    17  	// value is true.
    18  	AuthorizedDatabases *bool
    19  }
    20  
    21  // ListDatabases creates a new ListDatabasesOptions instance.
    22  func ListDatabases() *ListDatabasesOptions {
    23  	return &ListDatabasesOptions{}
    24  }
    25  
    26  // SetNameOnly sets the value for the NameOnly field.
    27  func (ld *ListDatabasesOptions) SetNameOnly(b bool) *ListDatabasesOptions {
    28  	ld.NameOnly = &b
    29  	return ld
    30  }
    31  
    32  // SetAuthorizedDatabases sets the value for the AuthorizedDatabases field.
    33  func (ld *ListDatabasesOptions) SetAuthorizedDatabases(b bool) *ListDatabasesOptions {
    34  	ld.AuthorizedDatabases = &b
    35  	return ld
    36  }
    37  
    38  // MergeListDatabasesOptions combines the given ListDatabasesOptions instances into a single *ListDatabasesOptions in a
    39  // last-one-wins fashion.
    40  //
    41  // Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create a
    42  // single options struct instead.
    43  func MergeListDatabasesOptions(opts ...*ListDatabasesOptions) *ListDatabasesOptions {
    44  	ld := ListDatabases()
    45  	for _, opt := range opts {
    46  		if opt == nil {
    47  			continue
    48  		}
    49  		if opt.NameOnly != nil {
    50  			ld.NameOnly = opt.NameOnly
    51  		}
    52  		if opt.AuthorizedDatabases != nil {
    53  			ld.AuthorizedDatabases = opt.AuthorizedDatabases
    54  		}
    55  	}
    56  
    57  	return ld
    58  }