db

package
v0.0.0-...-75ad9af Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DbUri  = "mongodb://localhost:27017"
	DbName = "hotel-reservation"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BookingStore

type BookingStore interface {
	InsertBooking(context.Context, *customtypes.Booking) (*customtypes.Booking, error)
	GetBookings(context.Context, bson.M) ([]*customtypes.Booking, error)
	GetBookingByID(context.Context, string) (*customtypes.Booking, error)
}

type Dropper

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

type HotelStore

type HotelStore interface {
	Dropper

	GetHotelByID(context.Context, bson.M) (*customtypes.Hotel, error)
	GetHotels(context.Context, bson.M) ([]*customtypes.Hotel, error)
	InsertHotel(context.Context, *customtypes.Hotel) (*customtypes.Hotel, error)
	UpdateHotel(context.Context, bson.M, bson.M) error
	DeleteHotel(context.Context, string) error
}

type MongoBookingStore

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

func NewMongoBookingStore

func NewMongoBookingStore(client *mongo.Client) *MongoBookingStore

func (*MongoBookingStore) GetBookingByID

func (db *MongoBookingStore) GetBookingByID(ctx context.Context, id string) (*customtypes.Booking, error)

func (*MongoBookingStore) GetBookings

func (db *MongoBookingStore) GetBookings(ctx context.Context, filter bson.M) ([]*customtypes.Booking, error)

func (*MongoBookingStore) InsertBooking

func (db *MongoBookingStore) InsertBooking(ctx context.Context, booking *customtypes.Booking) (*customtypes.Booking, error)

type MongoHotelStore

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

func NewMongoHotelStore

func NewMongoHotelStore(client *mongo.Client) *MongoHotelStore

func (*MongoHotelStore) DeleteHotel

func (db *MongoHotelStore) DeleteHotel(ctx context.Context, id string) error

func (*MongoHotelStore) Drop

func (db *MongoHotelStore) Drop(ctx context.Context) error

func (*MongoHotelStore) GetHotelByID

func (db *MongoHotelStore) GetHotelByID(ctx context.Context, filter bson.M) (*customtypes.Hotel, error)

func (*MongoHotelStore) GetHotels

func (db *MongoHotelStore) GetHotels(ctx context.Context, filter bson.M) ([]*customtypes.Hotel, error)

func (*MongoHotelStore) InsertHotel

func (db *MongoHotelStore) InsertHotel(ctx context.Context, hotel *customtypes.Hotel) (*customtypes.Hotel, error)

func (*MongoHotelStore) UpdateHotel

func (db *MongoHotelStore) UpdateHotel(ctx context.Context, filter, update bson.M) error

type MongoRoomStore

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

func NewMongoRoomStore

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

func (*MongoRoomStore) DeleteRoom

func (db *MongoRoomStore) DeleteRoom(ctx context.Context, id string) error

func (*MongoRoomStore) Drop

func (db *MongoRoomStore) Drop(ctx context.Context) error

func (*MongoRoomStore) GetRoomByID

func (db *MongoRoomStore) GetRoomByID(ctx context.Context, id string) (*customtypes.Room, error)

func (*MongoRoomStore) GetRooms

func (db *MongoRoomStore) GetRooms(ctx context.Context, filter bson.M) ([]*customtypes.Room, error)

func (*MongoRoomStore) InsertRoom

func (db *MongoRoomStore) InsertRoom(ctx context.Context, room *customtypes.Room) (*customtypes.Room, error)

func (*MongoRoomStore) UpdateRoom

func (db *MongoRoomStore) UpdateRoom(ctx context.Context, filter bson.M, values customtypes.UpdateRoomParams) error

type MongoUserStore

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

func NewMongoUserStore

func NewMongoUserStore(client *mongo.Client) *MongoUserStore

func (*MongoUserStore) DeleteUser

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

func (*MongoUserStore) Drop

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

func (*MongoUserStore) GetUserByEmail

func (db *MongoUserStore) GetUserByEmail(ctx context.Context, email string) (*customtypes.User, error)

func (*MongoUserStore) GetUserByID

func (db *MongoUserStore) GetUserByID(ctx context.Context, id string) (*customtypes.User, error)

func (*MongoUserStore) GetUsers

func (db *MongoUserStore) GetUsers(ctx context.Context) ([]*customtypes.User, error)

func (*MongoUserStore) InsertUser

func (db *MongoUserStore) InsertUser(ctx context.Context, user *customtypes.User) (*customtypes.User, error)

func (*MongoUserStore) UpdateUser

func (db *MongoUserStore) UpdateUser(ctx context.Context, filter bson.M, params customtypes.UpdateUserParams) error

type RoomStore

type RoomStore interface {
	Dropper

	GetRoomByID(context.Context, string) (*customtypes.Room, error)
	GetRooms(context.Context, bson.M) ([]*customtypes.Room, error)
	InsertRoom(context.Context, *customtypes.Room) (*customtypes.Room, error)
	UpdateRoom(context.Context, bson.M, customtypes.UpdateRoomParams) error
	DeleteRoom(context.Context, string) error
}

type Store

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

type UserStore

type UserStore interface {
	Dropper

	GetUserByID(context.Context, string) (*customtypes.User, error)
	GetUserByEmail(context.Context, string) (*customtypes.User, error)
	GetUsers(context.Context) ([]*customtypes.User, error)
	InsertUser(context.Context, *customtypes.User) (*customtypes.User, error)
	UpdateUser(context.Context, bson.M, customtypes.UpdateUserParams) error
	DeleteUser(context.Context, string) error
}

Jump to

Keyboard shortcuts

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