github.com/mdaxf/iac@v0.0.0-20240519030858-58a061660378/vendor_skip/go.mongodb.org/mongo-driver/mongo/index_options_builder.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 mongo 8 9 import ( 10 "go.mongodb.org/mongo-driver/bson" 11 ) 12 13 // IndexOptionsBuilder specifies options for a new index. 14 // 15 // Deprecated: Use the IndexOptions type in the mongo/options package instead. 16 type IndexOptionsBuilder struct { 17 document bson.D 18 } 19 20 // NewIndexOptionsBuilder creates a new IndexOptionsBuilder. 21 // 22 // Deprecated: Use the Index function in mongo/options instead. 23 func NewIndexOptionsBuilder() *IndexOptionsBuilder { 24 return &IndexOptionsBuilder{} 25 } 26 27 // Background specifies a value for the background option. 28 // 29 // Deprecated: Use the IndexOptions.SetBackground function in mongo/options instead. 30 func (iob *IndexOptionsBuilder) Background(background bool) *IndexOptionsBuilder { 31 iob.document = append(iob.document, bson.E{"background", background}) 32 return iob 33 } 34 35 // ExpireAfterSeconds specifies a value for the expireAfterSeconds option. 36 // 37 // Deprecated: Use the IndexOptions.SetExpireAfterSeconds function in mongo/options instead. 38 func (iob *IndexOptionsBuilder) ExpireAfterSeconds(expireAfterSeconds int32) *IndexOptionsBuilder { 39 iob.document = append(iob.document, bson.E{"expireAfterSeconds", expireAfterSeconds}) 40 return iob 41 } 42 43 // Name specifies a value for the name option. 44 // 45 // Deprecated: Use the IndexOptions.SetName function in mongo/options instead. 46 func (iob *IndexOptionsBuilder) Name(name string) *IndexOptionsBuilder { 47 iob.document = append(iob.document, bson.E{"name", name}) 48 return iob 49 } 50 51 // Sparse specifies a value for the sparse option. 52 // 53 // Deprecated: Use the IndexOptions.SetSparse function in mongo/options instead. 54 func (iob *IndexOptionsBuilder) Sparse(sparse bool) *IndexOptionsBuilder { 55 iob.document = append(iob.document, bson.E{"sparse", sparse}) 56 return iob 57 } 58 59 // StorageEngine specifies a value for the storageEngine option. 60 // 61 // Deprecated: Use the IndexOptions.SetStorageEngine function in mongo/options instead. 62 func (iob *IndexOptionsBuilder) StorageEngine(storageEngine interface{}) *IndexOptionsBuilder { 63 iob.document = append(iob.document, bson.E{"storageEngine", storageEngine}) 64 return iob 65 } 66 67 // Unique specifies a value for the unique option. 68 // 69 // Deprecated: Use the IndexOptions.SetUnique function in mongo/options instead. 70 func (iob *IndexOptionsBuilder) Unique(unique bool) *IndexOptionsBuilder { 71 iob.document = append(iob.document, bson.E{"unique", unique}) 72 return iob 73 } 74 75 // Version specifies a value for the version option. 76 // 77 // Deprecated: Use the IndexOptions.SetVersion function in mongo/options instead. 78 func (iob *IndexOptionsBuilder) Version(version int32) *IndexOptionsBuilder { 79 iob.document = append(iob.document, bson.E{"v", version}) 80 return iob 81 } 82 83 // DefaultLanguage specifies a value for the default_language option. 84 // 85 // Deprecated: Use the IndexOptions.SetDefaultLanguage function in mongo/options instead. 86 func (iob *IndexOptionsBuilder) DefaultLanguage(defaultLanguage string) *IndexOptionsBuilder { 87 iob.document = append(iob.document, bson.E{"default_language", defaultLanguage}) 88 return iob 89 } 90 91 // LanguageOverride specifies a value for the language_override option. 92 // 93 // Deprecated: Use the IndexOptions.SetLanguageOverride function in mongo/options instead. 94 func (iob *IndexOptionsBuilder) LanguageOverride(languageOverride string) *IndexOptionsBuilder { 95 iob.document = append(iob.document, bson.E{"language_override", languageOverride}) 96 return iob 97 } 98 99 // TextVersion specifies a value for the textIndexVersion option. 100 // 101 // Deprecated: Use the IndexOptions.SetTextVersion function in mongo/options instead. 102 func (iob *IndexOptionsBuilder) TextVersion(textVersion int32) *IndexOptionsBuilder { 103 iob.document = append(iob.document, bson.E{"textIndexVersion", textVersion}) 104 return iob 105 } 106 107 // Weights specifies a value for the weights option. 108 // 109 // Deprecated: Use the IndexOptions.SetWeights function in mongo/options instead. 110 func (iob *IndexOptionsBuilder) Weights(weights interface{}) *IndexOptionsBuilder { 111 iob.document = append(iob.document, bson.E{"weights", weights}) 112 return iob 113 } 114 115 // SphereVersion specifies a value for the 2dsphereIndexVersion option. 116 // 117 // Deprecated: Use the IndexOptions.SetSphereVersion function in mongo/options instead. 118 func (iob *IndexOptionsBuilder) SphereVersion(sphereVersion int32) *IndexOptionsBuilder { 119 iob.document = append(iob.document, bson.E{"2dsphereIndexVersion", sphereVersion}) 120 return iob 121 } 122 123 // Bits specifies a value for the bits option. 124 // 125 // Deprecated: Use the IndexOptions.SetBits function in mongo/options instead. 126 func (iob *IndexOptionsBuilder) Bits(bits int32) *IndexOptionsBuilder { 127 iob.document = append(iob.document, bson.E{"bits", bits}) 128 return iob 129 } 130 131 // Max specifies a value for the max option. 132 // 133 // Deprecated: Use the IndexOptions.SetMax function in mongo/options instead. 134 func (iob *IndexOptionsBuilder) Max(max float64) *IndexOptionsBuilder { 135 iob.document = append(iob.document, bson.E{"max", max}) 136 return iob 137 } 138 139 // Min specifies a value for the min option. 140 // 141 // Deprecated: Use the IndexOptions.SetMin function in mongo/options instead. 142 func (iob *IndexOptionsBuilder) Min(min float64) *IndexOptionsBuilder { 143 iob.document = append(iob.document, bson.E{"min", min}) 144 return iob 145 } 146 147 // BucketSize specifies a value for the bucketSize option. 148 // 149 // Deprecated: Use the IndexOptions.SetBucketSize function in mongo/options instead. 150 func (iob *IndexOptionsBuilder) BucketSize(bucketSize int32) *IndexOptionsBuilder { 151 iob.document = append(iob.document, bson.E{"bucketSize", bucketSize}) 152 return iob 153 } 154 155 // PartialFilterExpression specifies a value for the partialFilterExpression option. 156 // 157 // Deprecated: Use the IndexOptions.SetPartialFilterExpression function in mongo/options instead. 158 func (iob *IndexOptionsBuilder) PartialFilterExpression(partialFilterExpression interface{}) *IndexOptionsBuilder { 159 iob.document = append(iob.document, bson.E{"partialFilterExpression", partialFilterExpression}) 160 return iob 161 } 162 163 // Collation specifies a value for the collation option. 164 // 165 // Deprecated: Use the IndexOptions.SetCollation function in mongo/options instead. 166 func (iob *IndexOptionsBuilder) Collation(collation interface{}) *IndexOptionsBuilder { 167 iob.document = append(iob.document, bson.E{"collation", collation}) 168 return iob 169 } 170 171 // Build finishes constructing an the builder. 172 // 173 // Deprecated: Use the IndexOptions type in the mongo/options package instead. 174 func (iob *IndexOptionsBuilder) Build() bson.D { 175 return iob.document 176 }