database

package
v0.0.0-...-6cd009c Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DBClient *mongo.Client

Functions

func CreateDBInstance

func CreateDBInstance()

func DoesIndexExist

func DoesIndexExist(ctx context.Context, collection *mongo.Collection, indexName string) (bool, error)

Types

type ClickEvent

type ClickEvent struct {
	URLId     string      `json:"url_id,omitempty"`
	Geo       CountryName `json:"geo"`
	Device    string      `json:"device"`
	OS        string      `json:"os"`
	Referrer  string      `json:"referrer"`
	Timestamp UnixTime    `json:"timestamp"`
}

type CountryName

type CountryName string

type DB

type DB struct {
	User *mongo.Collection
	Url  *mongo.Collection
	// RedirectEvent *mongo.Collection
	Config *mongo.Collection
}
var CurrentDb *DB

type DBIndexName

type DBIndexName string
const UrlShortIndexName DBIndexName = "url_short_index_1"

type URL

type URL struct {
	User        primitive.ObjectID `json:"user,omitempty" bson:"user,omitempty"`
	UserDoc     *User              `json:"user_obj" bson:"-"`
	Destination string             `json:"destination" validate:"required"`
	Expiry      UnixTime           `json:"expiry" validate:"required"`
	Short       string             `json:"short" validate:"required"`
	ID          primitive.ObjectID `json:"_id,omitempty" bson:"_id,omitempty"`
	UpdateAt    UnixTime           `json:"update_at" bson:"update_at"`
	CreatedAt   UnixTime           `json:"created_at" bson:"created_at"`
	TotalClicks int64              `json:"total_clicks" bson:"total_clicks"`
	Temporary   bool               `json:"temporary" bson:"temporary"`
}

type UnixTime

type UnixTime int64

func (*UnixTime) Scan

func (ut *UnixTime) Scan(value interface{}) error

func (UnixTime) Value

func (u UnixTime) Value() (driver.Value, error)

type User

type User struct {
	Name      string             `json:"name" validate:"required"`
	Email     string             `json:"email" validate:"required"`
	Picture   string             `json:"picture" validate:"required"`
	Token     string             `json:"token" bson:"-"`
	ID        primitive.ObjectID `json:"_id,omitempty"  bson:"_id,omitempty"`
	CreatedAt UnixTime           `json:"created_at" validate:"required"`
}

Jump to

Keyboard shortcuts

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