Documentation ¶
Index ¶
- Constants
- type ClientOptions
- type CollectionDef
- type Connection
- func (c *Connection) Coll(name string) *mongo.Collection
- func (c *Connection) DefineCollections(defs []CollectionDef) error
- func (c *Connection) InsertOne(coll string, data any) (res *mongo.InsertOneResult, err error)
- func (c *Connection) UpsertOne(coll string, filter any, data any) (res *mongo.UpdateResult, err error)
- type EnvClientConfig
- type IndexDef
- type TimeseriesDef
Constants ¶
View Source
const DefaultTimeout = 2000 * time.Millisecond
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientOptions ¶
type ClientOptions struct { Uri string `validation:"required"` Database string `validation:"required"` Timeout time.Duration }
func ClientOptionsFromEnvConfig ¶
func ClientOptionsFromEnvConfig(cfg EnvClientConfig) ClientOptions
type CollectionDef ¶
type CollectionDef struct { Name string Timeseries *TimeseriesDef Indexes []IndexDef }
type Connection ¶
type Connection struct { Client *mongo.Client DB *mongo.Database Logger *slog.Logger // contains filtered or unexported fields }
func Connect ¶
func Connect(config ClientOptions) (conn *Connection, err error)
func (*Connection) Coll ¶
func (c *Connection) Coll(name string) *mongo.Collection
func (*Connection) DefineCollections ¶
func (c *Connection) DefineCollections(defs []CollectionDef) error
func (*Connection) InsertOne ¶
func (c *Connection) InsertOne(coll string, data any) (res *mongo.InsertOneResult, err error)
func (*Connection) UpsertOne ¶
func (c *Connection) UpsertOne(coll string, filter any, data any) (res *mongo.UpdateResult, err error)
type EnvClientConfig ¶
type TimeseriesDef ¶
Click to show internal directories.
Click to hide internal directories.