commentdb

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const CommentCollection = "comments"

CommentCollection is the MongoDB collection name that holds all comments.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database interface {
	// Create creates a new comment.
	Create(ctx context.Context, key string, userId, message string) (string, error)
	// Reply replies to a comment.
	Reply(ctx context.Context, id string, userId, message string) (string, error)
	// ByID returns a singel comment by ID.
	ByID(ctx context.Context, id string) (*v1alpha.Comment, error)
	// ByKey returns all comments that are associated with key.
	ByKey(ctx context.Context, key string, prefix bool) ([]v1alpha.Comment, error)
}

func New

func New(ctx context.Context, url, dbName string) (Database, error)

New connects to the MongoDB server at URL and returns a new database interface.

func NewWithClient

func NewWithClient(ctx context.Context, dbName string, client *mongo.Client) (Database, error)

NewWithClient is like New but uses an already existing mongodb client.

Jump to

Keyboard shortcuts

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