database

package
v0.0.0-...-9fdc65e Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Insert = "INSERT"
	Update = "UPDATE"
	Delete = "DELETE"
)

Operations the API performs on the database, to be sent as OP header through NATS

Variables

View Source
var (
	// ErrChannelAlreadyExists is returned when trying to add a channel that already exists in the database
	ErrChannelAlreadyExists = errors.New("channel already exists")
	// ErrChannelNotFound is returned when the channel you're trying to perform an operation on doesn't exist
	ErrChannelNotFound = errors.New("channel not found")
)

Functions

func Connect

func Connect(uri, username, password, database string) error

func DeleteChannel

func DeleteChannel(ctx context.Context, id int64) error

DeleteChannel deletes a channel by ID, returns an error if the channel ID was not found

func EnsureCollection

func EnsureCollection(coll string)

func GetChannel

func GetChannel(ctx context.Context, filter bson.D) (*types.Channel, error)

GetChannel finds a single channel based on the BSON filter provided

func GetChannels

func GetChannels(ctx context.Context, cb func([]types.Channel), batchSize int) error

GetChannels gets all channels, and runs the given callback in batches, where channels with the highest weight get the highest priority

func InsertChannel

func InsertChannel(ctx context.Context, channel types.Channel) error

InsertChannel inserts a channel, returns error if it already exists

func Ping

func Ping() error

func UpsertChannel

func UpsertChannel(ctx context.Context, channel types.Channel) error

UpsertChannel inserts a channel, or updates it if it already exists

Types

This section is empty.

Jump to

Keyboard shortcuts

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