db

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2023 License: Apache-2.0 Imports: 10 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Client *mongo.Client

	Domains  *mongo.Collection
	NotFound *mongo.Collection
)

Functions

func Connect

func Connect(uri string) error

Connect connects to the database using the standard Connection URI.

func Disconnect

func Disconnect() error

Disconnect gracefully disconnect from the database.

func GetStat

func GetStat() (int64, error)

GetStat returns the total number of domains.

func Insert

func Insert(d string) (bool, error)

Insert inserts the given domain d to the *domains* database. Checks if d is valid, do a Clean() and then splits into sub|domain|tld parts.

Returns true if d is new and inserted into the database. If domain is invalid, returns fault.ErrInvalidDomain. If failed to get parts of d (eg.: d is a TLD), returns ault.ErrGetPartsFailed.

func InsertNotFound added in v0.10.0

func InsertNotFound(d string) (bool, error)

InsertNotFound inserts the given domain d to the *notFound* database. Checks if d is valid, do a Clean() and removes the subdomain from d.

If domain is invalid or failed to remove the subdomain, returns fault.ErrInvalidDomain.

func Lookup

func Lookup(d string) ([]string, error)

Lookup query the DB and returns a list subdomains.

If d has a subdomain, removes it before the query.

If d is invalid return fault.ErrInvalidDomain. If failed to get parts of d (eg.: d is a TLD), returns ault.ErrGetPartsFailed.

func TLD added in v0.6.0

func TLD(d string) ([]string, error)

TLD query the DB and returns a list of TLDs for the given domain d.

Domain d must be a valid Second Level Domain (eg.: "example").

NOTE: This function not validate adn Clean() d!

Types

type NotFoundSchema added in v0.10.0

type NotFoundSchema struct {
	Domain string `bson:"domain" json:"domain"`
}

Schema used in *notFound* collection

Jump to

Keyboard shortcuts

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