ensure

package
v0.0.0-...-78bde44 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package ensure defines a mechanism that ensures mongodb to setup index, capped collections etc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Field

func Field(ctx context.Context, coll *mongo.Collection, field string, val interface{}) error

Field is a help ensure function to set field if it dose not exist. It is not an error if the collection is not exist.

func RegisterEnsure

func RegisterEnsure(pkg, name string, fn Func)

RegisterEnsure register an ensure function to be part of database ensure process. Database ensure process is started by "mongo" life cycle package.

Do not assume ensure functions runs at any specific order. Normally, for mongodb order is not important.

pkg and name generate log message, do not need to be unique.

Types

type Func

type Func func(ctx context.Context, db *mongo.Database) error

Func is a callback to ensure database feature enabled, such as index, capped collection etc.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL