mongoadaptor

package
v0.0.0-...-00f7b3d Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMongoConsumer

func NewMongoConsumer(topic string, db *mongo.Database) *se.Consumer

Types

type MongoRequest

type MongoRequest struct {
	ID         string      `json:"id" bson:"_id"` // Private field for ID
	ExternalID string      `json:"externalid" bson:"externalid"`
	Request    se.Request  `json:"request"`
	Topic      string      `json:"topic" bson:"topic"` //optional
	Status     MongoStatus `json:"mongostatus" bson:"mongostatus"`
	Created    time.Time   `json:"created" bson:"created"`
	Updated    time.Time   `json:"updated" bson:"updated"`
}

func Fetch

func Fetch(cl *mongo.Collection, id, externalid, topic string, status MongoStatus) ([]MongoRequest, error)

Pass any string as "" for id, externalid, topic to be ignored for filter and status as MongoStatusAny to ignore

func NewMongoRequest

func NewMongoRequest(req se.Request) *MongoRequest

func (*MongoRequest) Delete

func (m *MongoRequest) Delete(cl *mongo.Collection) error

func (*MongoRequest) Save

func (m *MongoRequest) Save(cl *mongo.Collection) error

This will insert only.

func (*MongoRequest) Update

func (m *MongoRequest) Update(cl *mongo.Collection) error

This will update or insert based on if the id exists or not

type MongoStatus

type MongoStatus string
const (
	MongoStatusAny       MongoStatus = ""
	MongoStatusNew       MongoStatus = "new"
	MongoStatusProcessed MongoStatus = "processed"
)

Jump to

Keyboard shortcuts

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