db

package
v0.0.0-...-d3bd4fd Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2023 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectDB

func ConnectDB(connectionString string) (*mongo.Client, context.Context)

ConnectDB creates and returns a client connected by a connection string to mongoDB. Also checks the connection if everything is ok.

func GetDatabase

func GetDatabase(client *mongo.Client, databaseName string) *mongo.Database

GetDatabase returns the pointer to the database d(input).

func GetUsers

func GetUsers(database *mongo.Database) *mongo.Collection

GetUsers returns the collection of users

func GetWebsites

func GetWebsites(database *mongo.Database) *mongo.Collection

GetWebsites returns the collection of websites

func InsertUser

func InsertUser(connString string, dbName string, user User)

InsertUser inserts an user into the collection users

func InsertUsers

func InsertUsers(connString string, dbName string, users []User)

InsertUsers inserts into the collection users in database d(input) a slice of users inputted.

func InsertWebsite

func InsertWebsite(connString string, dbName string, website Website)

InsertWebsite inserts a website url into the collection websites

func InsertWebsites

func InsertWebsites(connString string, dbName string, websites []Website)

InsertWebsites inserts into the collection websites in database d(input) a slice of websites inputted.

Types

type User

type User struct {
	Email string `json:"email Str"`
}

User

func GetAllUsers

func GetAllUsers(connString string, dbName string) []User

TODO

type Website

type Website struct {
	Address   string `json:"address Str"`
	Body      string `json:"body Str"`
	Seconds   int    `json:"seconds Int"`
	Timestamp int64  `json:"timestamp Int"`
}

Website

func GetAllWebsites

func GetAllWebsites(connString string, dbName string) []Website

TODO

Jump to

Keyboard shortcuts

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