db

package
v0.0.0-...-2c40a9a Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const MongoDBEnvName = "MONGO_DB_NAME"

Variables

This section is empty.

Functions

This section is empty.

Types

type BookingStore

type BookingStore interface {
	Insert(context.Context, *types.Booking) (*types.Booking, error)
	Get(context.Context, Map) ([]*types.Booking, error)
	GetByID(context.Context, string) (*types.Booking, error)
	Update(context.Context, string, Map) error
}

type Dropper

type Dropper interface {
	Drop(context.Context) error
}

type HotelStore

type HotelStore interface {
	Insert(context.Context, *types.Hotel) (*types.Hotel, error)
	Update(context.Context, Map, Map) error
	Get(context.Context, Map, *Pagination) ([]*types.Hotel, error)
	GetByID(context.Context, string) (*types.Hotel, error)
}

type Map

type Map map[string]any

type MongoBookingStore

type MongoBookingStore struct {
	// contains filtered or unexported fields
}

func NewMongoBookingStore

func NewMongoBookingStore(client *mongo.Client) *MongoBookingStore

func (*MongoBookingStore) Get

func (s *MongoBookingStore) Get(ctx context.Context, filter Map) ([]*types.Booking, error)

func (*MongoBookingStore) GetByID

func (s *MongoBookingStore) GetByID(ctx context.Context, id string) (*types.Booking, error)

func (*MongoBookingStore) Insert

func (s *MongoBookingStore) Insert(ctx context.Context, booking *types.Booking) (*types.Booking, error)

func (*MongoBookingStore) Update

func (s *MongoBookingStore) Update(ctx context.Context, id string, update Map) error

type MongoHotelStore

type MongoHotelStore struct {
	// contains filtered or unexported fields
}

func NewMongoHotelStore

func NewMongoHotelStore(client *mongo.Client) *MongoHotelStore

func (*MongoHotelStore) Get

func (s *MongoHotelStore) Get(ctx context.Context, filter Map, pagination *Pagination) ([]*types.Hotel, error)

func (*MongoHotelStore) GetByID

func (s *MongoHotelStore) GetByID(ctx context.Context, id string) (*types.Hotel, error)

func (*MongoHotelStore) Insert

func (s *MongoHotelStore) Insert(ctx context.Context, hotel *types.Hotel) (*types.Hotel, error)

func (*MongoHotelStore) Update

func (s *MongoHotelStore) Update(ctx context.Context, filter Map, update Map) error

type MongoRoomStore

type MongoRoomStore struct {
	HotelStore
	// contains filtered or unexported fields
}

func NewMongoRoomStore

func NewMongoRoomStore(client *mongo.Client, hotelStore HotelStore) *MongoRoomStore

func (*MongoRoomStore) Get

func (s *MongoRoomStore) Get(ctx context.Context, filter Map) ([]*types.Room, error)

func (*MongoRoomStore) Insert

func (s *MongoRoomStore) Insert(ctx context.Context, room *types.Room) (*types.Room, error)

type MongoUserStore

type MongoUserStore struct {
	// contains filtered or unexported fields
}

func NewMongoUserStore

func NewMongoUserStore(client *mongo.Client) *MongoUserStore

func (*MongoUserStore) DeleteUser

func (s *MongoUserStore) DeleteUser(ctx context.Context, id string) error

func (*MongoUserStore) Drop

func (s *MongoUserStore) Drop(ctx context.Context) error

func (*MongoUserStore) GetByEmail

func (s *MongoUserStore) GetByEmail(ctx context.Context, email string) (*types.User, error)

func (*MongoUserStore) GetUserByID

func (s *MongoUserStore) GetUserByID(ctx context.Context, id string) (*types.User, error)

func (*MongoUserStore) GetUsers

func (s *MongoUserStore) GetUsers(ctx context.Context) ([]*types.User, error)

func (*MongoUserStore) InsertUser

func (s *MongoUserStore) InsertUser(ctx context.Context, user *types.User) (*types.User, error)

func (*MongoUserStore) UpdateUser

func (s *MongoUserStore) UpdateUser(ctx context.Context, id string, params types.UpdateUserParams) error

type Pagination

type Pagination struct {
	Limit int64
	Page  int64
}

type RoomStore

type RoomStore interface {
	Insert(context.Context, *types.Room) (*types.Room, error)
	Get(context.Context, Map) ([]*types.Room, error)
}

type Store

type Store struct {
	User    UserStore
	Hotel   HotelStore
	Room    RoomStore
	Booking BookingStore
}

type UserStore

type UserStore interface {
	Dropper

	GetByEmail(context.Context, string) (*types.User, error)
	GetUserByID(context.Context, string) (*types.User, error)
	GetUsers(context.Context) ([]*types.User, error)
	InsertUser(context.Context, *types.User) (*types.User, error)
	DeleteUser(context.Context, string) error
	UpdateUser(context.Context, string, types.UpdateUserParams) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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