mongo

package
v0.0.0-...-d27e4ba Latest Latest
Warning

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

Go to latest
Published: May 31, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatState

type ChatState struct {
	ID           primitive.ObjectID `bson:"_id,omitempty"`
	ChatID       int64              `bson:"chat_id,omitempty"`
	AwaitInput   string             `bson:"await_input"`
	DisableInput bool               `bson:"disable_input"`
}

type ChatStateUpdate

type ChatStateUpdate struct {
	AwaitInput   string `bson:"await_input"`
	DisableInput bool   `bson:"disable_input"`
}

type ObserveArea

type ObserveArea struct {
	Type        string `bson:"type"`
	Coordinates []Path `bson:"coordinates"`
}

ObserveArea is a GeoJSON type.

func NewObserveArea

func NewObserveArea(path Path) *ObserveArea

NewObserveArea creates a GeoJSON type Polygon with a single path (called exterior ring).

type Path

type Path []PointAsArray

type Point

type Point struct {
	Lat float64 `bson:"lat,omitempty"`
	Lng float64 `bson:"lng,omitempty"`
}

Point represents a GeoJSON type

func (Point) ToArray

func (p Point) ToArray() (arr PointAsArray)

type PointAsArray

type PointAsArray [2]float64

PointAsArray represents a GeoJSON Point in array format. First element is longitude, second is latitude.

type Storage

type Storage struct {
	Client *mongo.Client
	// contains filtered or unexported fields
}

func NewStorage

func NewStorage(uri, namespace string) (*Storage, error)

func (*Storage) CreateSubscription

func (s *Storage) CreateSubscription(chatID int64, name string) (*entity.Subscription, error)

func (*Storage) DeleteSubscription

func (s *Storage) DeleteSubscription(subHexID string) error

func (*Storage) GetChatState

func (s *Storage) GetChatState(chatID int64) *entity.ChatState

func (*Storage) GetEventSubscribers

func (s *Storage) GetEventSubscribers(eventData entity.EventData) (chatIDs []int64, err error)

func (*Storage) GetSubscription

func (s *Storage) GetSubscription(subHexID string) (*entity.Subscription, error)

func (*Storage) GetSubscriptions

func (s *Storage) GetSubscriptions(chatID int64) (subs []entity.Subscription)

func (*Storage) SetChatState

func (s *Storage) SetChatState(
	chatID int64, update *entity.ChatStateUpdate,
) (*entity.ChatState, error)

func (*Storage) UpdateSubscription

func (s *Storage) UpdateSubscription(
	subHexID string, subUpdate *entity.SubscriptionUpdate,
) (*entity.Subscription, error)

type Subscription

type Subscription struct {
	ID          primitive.ObjectID `bson:"_id,omitempty"`
	Name        string             `bson:"name,omitempty"`
	ChatID      int64              `bson:"chat_id,omitempty"`
	MinMag      float64            `bson:"min_mag,omitempty"`
	Delay       float64            `bson:"delay,omitempty"`
	Location    *Point             `bson:"location,omitempty"`
	Radius      float64            `bson:"radius,omitempty"`
	ObserveArea *ObserveArea       `bson:"observe_area,omitempty"`
	Sources     []string           `bson:"sources,omitempty"`
}

type SubscriptionChatID

type SubscriptionChatID struct {
	ChatID int64 `bson:"chat_id,omitempty"`
}

type SubscriptionUpdate

type SubscriptionUpdate struct {
	Name        string       `bson:"name,omitempty"`
	MinMag      float64      `bson:"min_mag,omitempty"`
	Delay       float64      `bson:"delay,omitempty"`
	Location    *Point       `bson:"location,omitempty"`
	Radius      float64      `bson:"radius"`
	ObserveArea *ObserveArea `bson:"observe_area,omitempty"`
	Sources     []string     `bson:"sources,omitempty"`
}

Jump to

Keyboard shortcuts

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