db

package
v0.0.0-...-2f3150d Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ConnectionTimeout is the default timeout for connecting to the database.
	ConnectionTimeout = 60 * time.Second

	// DatabaseName is the name of the database
	DatabaseName = "ado-asana-sync"

	// Timeout is the default timeout for database operations.
	Timeout = 10 * time.Second
)
View Source
var (
	// LastSyncCollection is the name of the collection in the database
	LastSyncCollection = "last_sync"
)
View Source
var (
	// ProjectsCollection is the name of the collection in the database
	ProjectsCollection = "projects"
)

Functions

This section is empty.

Types

type DB

type DB struct {
	Client *mongo.Client
}

func (*DB) AddProject

func (db *DB) AddProject(ctx context.Context, project Project) error

AddProject adds a new project to the database. It takes a Project struct as input and returns an error, if any.

func (*DB) Connect

func (db *DB) Connect(ctx context.Context, uri string) error

func (*DB) LastSync

func (db *DB) LastSync(ctx context.Context) LastSync

LastSync retrieves the last sync time.

func (*DB) Projects

func (db *DB) Projects(ctx context.Context) ([]Project, error)

Projects retrieves all projects from the database. It returns a slice of Project structs and an error, if any.

func (*DB) RemoveProject

func (db *DB) RemoveProject(ctx context.Context, id primitive.ObjectID) error

RemoveProject removes a project from the database based on its ID. It takes an ID ObjectID as input and returns an error, if any.

func (*DB) UpdateProject

func (db *DB) UpdateProject(ctx context.Context, project Project) error

UpdateProject updates an existing project in the database. It takes a Project struct as input and returns an error, if any.

func (*DB) WriteLastSync

func (db *DB) WriteLastSync(ctx context.Context, timestamp time.Time) error

WriteLastSync updates the last sync time in the database.

type LastSync

type LastSync struct {
	Time time.Time `json:"time" bson:"time"`
}

LastSync represents a lastSync record.

type Project

type Project struct {
	ID                 primitive.ObjectID `json:"id" bson:"_id"`
	ADOProjectName     string             `json:"ado_project_name" bson:"ado_project_name"`
	ADOTeamName        string             `json:"ado_team_name" bson:"ado_team_name"`
	AsanaProjectName   string             `json:"asana_project_name" bson:"asana_project_name"`
	AsanaWorkspaceName string             `json:"asana_workspace_name" bson:"asana_workspace_name"`
}

Project represents a project with its corresponding names in ADO and Asana.

Jump to

Keyboard shortcuts

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