db

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2023 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() (*MongoDB, error)

func (*MongoDB) Create

func (d *MongoDB) Create(data Note) (Note, error)

func (*MongoDB) Delete

func (d *MongoDB) Delete(id string) (Note, error)

func (*MongoDB) Get

func (d *MongoDB) Get(id string) (Note, error)

func (*MongoDB) List

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

func (*MongoDB) Tags

func (d *MongoDB) Tags() ([]string, error)

func (*MongoDB) Update

func (d *MongoDB) Update(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"`
	Score    int                `bson:"_score" json:"_score,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(filter, sort string, tags []string) ([]Note, error)
	Get(id string) (Note, error)
	Create(data Note) (Note, error)
	Update(data Note) error
	Delete(id string) (Note, error)
	Tags() ([]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