db

package
v0.0.0-...-16e66dc Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database interface {
	FetchByShort(link string) ([]string, error)
	FetchByLong(link string) ([]string, error)
	Insert(long string, short string) error

	Disconnect() error
}

type LinkPair

type LinkPair struct {
	ID    primitive.ObjectID `bson:"_id,omitempty"`
	Long  string             `bson:"long,omitempty"`
	Short string             `bson:"short,omitempty"`
}

type MongoDatabase

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

func Connect

func Connect(uri string, database string, collection string) (*MongoDatabase, error)

func (*MongoDatabase) Disconnect

func (mdb *MongoDatabase) Disconnect() error

func (*MongoDatabase) FetchByLong

func (mdb *MongoDatabase) FetchByLong(link string) ([]string, error)

func (*MongoDatabase) FetchByShort

func (mdb *MongoDatabase) FetchByShort(link string) ([]string, error)

func (*MongoDatabase) Insert

func (mdb *MongoDatabase) Insert(long string, short string) error

Jump to

Keyboard shortcuts

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