db

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MongoDB

type MongoDB struct {
	// contains filtered or unexported fields
}

func NewMongoDB

func NewMongoDB(ctx context.Context) (*MongoDB, error)

func (*MongoDB) Create

func (d *MongoDB) Create(ctx context.Context, data Note) (Note, error)

func (*MongoDB) Delete

func (d *MongoDB) Delete(ctx context.Context, id string) (Note, error)

func (*MongoDB) Get

func (d *MongoDB) Get(ctx context.Context, id string) (Note, error)

func (*MongoDB) List

func (d *MongoDB) List(ctx context.Context, filter, sort string, tags []string) ([]Note, error)

func (*MongoDB) Tags

func (d *MongoDB) Tags(ctx context.Context) ([]string, error)

func (*MongoDB) Update

func (d *MongoDB) Update(ctx context.Context, note Note) error

type Note

type Note struct {
	ID       primitive.ObjectID `bson:"_id" json:"id,omitempty"`
	Content  string             `bson:"content" json:"content"`
	Title    string             `bson:"title" json:"title"`
	Created  int                `bson:"created" json:"created,omitempty"`
	Updated  int                `bson:"updated" json:"updated,omitempty"`
	Tags     []string           `bson:"tags" json:"tags,omitempty"`
	Response *Response          `bson:"api_response" json:"api_response,omitempty"`
	Error    string             `bson:"error" json:"error,omitempty"`
}

type NoteNoID

type NoteNoID struct {
	Content string   `bson:"content" json:"content"`
	Title   string   `bson:"title" json:"title"`
	Created int      `bson:"created" json:"created,omitempty"`
	Updated int      `bson:"updated" json:"updated,omitempty"`
	Tags    []string `bson:"tags" json:"tags,omitempty"`
}

type NotesDatabase

type NotesDatabase interface {
	List(ctx context.Context, filter, sort string, tags []string) ([]Note, error)
	Get(ctx context.Context, id string) (Note, error)
	Create(ctx context.Context, data Note) (Note, error)
	Update(ctx context.Context, data Note) error
	Delete(ctx context.Context, id string) (Note, error)
	Tags(ctx context.Context) ([]string, error)
}
var DB NotesDatabase

type Response

type Response struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

Jump to

Keyboard shortcuts

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