mirror of
https://github.com/mainflux/mainflux.git
synced 2025-04-29 13:49:28 +08:00

* Update metadata type in things service Update things service so that metadata has map type. Update repo implementation by adding sqlx lib. Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Add sqlx lib to bootstrap service Add sqlx lib to bootstrap service and update metadata field type. Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Update metadata in redis streams consumer Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Update tests for bootstrap service Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Fix mongo reader logging and driver version Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Fix mongo reader and writer Fix mongo reader and writer by updating driver version. Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Update SDK with new metadata format Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Update LoRa adapter with new metadata format Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Update users service in order to use sqlx Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Replace anonymous struct with map Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Update docs for LoRa adapter Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Fix LoRa application metadata format Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Fix metadata format in LoRa docs Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Add metadata2 var to SDK things test Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>
135 lines
4.5 KiB
Go
135 lines
4.5 KiB
Go
// Copyright (C) MongoDB, Inc. 2017-present.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
// not use this file except in compliance with the License. You may obtain
|
|
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
package mongo
|
|
|
|
import (
|
|
"go.mongodb.org/mongo-driver/bson"
|
|
)
|
|
|
|
// IndexOptionsBuilder constructs a BSON document for index options
|
|
type IndexOptionsBuilder struct {
|
|
document bson.D
|
|
}
|
|
|
|
// NewIndexOptionsBuilder creates a new instance of IndexOptionsBuilder
|
|
func NewIndexOptionsBuilder() *IndexOptionsBuilder {
|
|
return &IndexOptionsBuilder{}
|
|
}
|
|
|
|
// Background sets the background option
|
|
func (iob *IndexOptionsBuilder) Background(background bool) *IndexOptionsBuilder {
|
|
iob.document = append(iob.document, bson.E{"background", background})
|
|
return iob
|
|
}
|
|
|
|
// ExpireAfterSeconds sets the expireAfterSeconds option
|
|
func (iob *IndexOptionsBuilder) ExpireAfterSeconds(expireAfterSeconds int32) *IndexOptionsBuilder {
|
|
iob.document = append(iob.document, bson.E{"expireAfterSeconds", expireAfterSeconds})
|
|
return iob
|
|
}
|
|
|
|
// Name sets the name option
|
|
func (iob *IndexOptionsBuilder) Name(name string) *IndexOptionsBuilder {
|
|
iob.document = append(iob.document, bson.E{"name", name})
|
|
return iob
|
|
}
|
|
|
|
// Sparse sets the sparse option
|
|
func (iob *IndexOptionsBuilder) Sparse(sparse bool) *IndexOptionsBuilder {
|
|
iob.document = append(iob.document, bson.E{"sparse", sparse})
|
|
return iob
|
|
}
|
|
|
|
// StorageEngine sets the storageEngine option
|
|
func (iob *IndexOptionsBuilder) StorageEngine(storageEngine interface{}) *IndexOptionsBuilder {
|
|
iob.document = append(iob.document, bson.E{"storageEngine", storageEngine})
|
|
return iob
|
|
}
|
|
|
|
// Unique sets the unique option
|
|
func (iob *IndexOptionsBuilder) Unique(unique bool) *IndexOptionsBuilder {
|
|
iob.document = append(iob.document, bson.E{"unique", unique})
|
|
return iob
|
|
}
|
|
|
|
// Version sets the version option
|
|
func (iob *IndexOptionsBuilder) Version(version int32) *IndexOptionsBuilder {
|
|
iob.document = append(iob.document, bson.E{"v", version})
|
|
return iob
|
|
}
|
|
|
|
// DefaultLanguage sets the defaultLanguage option
|
|
func (iob *IndexOptionsBuilder) DefaultLanguage(defaultLanguage string) *IndexOptionsBuilder {
|
|
iob.document = append(iob.document, bson.E{"default_language", defaultLanguage})
|
|
return iob
|
|
}
|
|
|
|
// LanguageOverride sets the languageOverride option
|
|
func (iob *IndexOptionsBuilder) LanguageOverride(languageOverride string) *IndexOptionsBuilder {
|
|
iob.document = append(iob.document, bson.E{"language_override", languageOverride})
|
|
return iob
|
|
}
|
|
|
|
// TextVersion sets the textVersion option
|
|
func (iob *IndexOptionsBuilder) TextVersion(textVersion int32) *IndexOptionsBuilder {
|
|
iob.document = append(iob.document, bson.E{"textIndexVersion", textVersion})
|
|
return iob
|
|
}
|
|
|
|
// Weights sets the weights option
|
|
func (iob *IndexOptionsBuilder) Weights(weights interface{}) *IndexOptionsBuilder {
|
|
iob.document = append(iob.document, bson.E{"weights", weights})
|
|
return iob
|
|
}
|
|
|
|
// SphereVersion sets the sphereVersion option
|
|
func (iob *IndexOptionsBuilder) SphereVersion(sphereVersion int32) *IndexOptionsBuilder {
|
|
iob.document = append(iob.document, bson.E{"2dsphereIndexVersion", sphereVersion})
|
|
return iob
|
|
}
|
|
|
|
// Bits sets the bits option
|
|
func (iob *IndexOptionsBuilder) Bits(bits int32) *IndexOptionsBuilder {
|
|
iob.document = append(iob.document, bson.E{"bits", bits})
|
|
return iob
|
|
}
|
|
|
|
// Max sets the max option
|
|
func (iob *IndexOptionsBuilder) Max(max float64) *IndexOptionsBuilder {
|
|
iob.document = append(iob.document, bson.E{"max", max})
|
|
return iob
|
|
}
|
|
|
|
// Min sets the min option
|
|
func (iob *IndexOptionsBuilder) Min(min float64) *IndexOptionsBuilder {
|
|
iob.document = append(iob.document, bson.E{"min", min})
|
|
return iob
|
|
}
|
|
|
|
// BucketSize sets the bucketSize option
|
|
func (iob *IndexOptionsBuilder) BucketSize(bucketSize int32) *IndexOptionsBuilder {
|
|
iob.document = append(iob.document, bson.E{"bucketSize", bucketSize})
|
|
return iob
|
|
}
|
|
|
|
// PartialFilterExpression sets the partialFilterExpression option
|
|
func (iob *IndexOptionsBuilder) PartialFilterExpression(partialFilterExpression interface{}) *IndexOptionsBuilder {
|
|
iob.document = append(iob.document, bson.E{"partialFilterExpression", partialFilterExpression})
|
|
return iob
|
|
}
|
|
|
|
// Collation sets the collation option
|
|
func (iob *IndexOptionsBuilder) Collation(collation interface{}) *IndexOptionsBuilder {
|
|
iob.document = append(iob.document, bson.E{"collation", collation})
|
|
return iob
|
|
}
|
|
|
|
// Build returns the BSON document from the builder
|
|
func (iob *IndexOptionsBuilder) Build() bson.D {
|
|
return iob.document
|
|
}
|