data

package
v0.0.0-...-cb57d40 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: Apache-2.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ScopeActivation     = "activation"
	ScopeAuthentication = "authentication"
	ScopePasswordReset  = "password-reset"
)

Variables

View Source
var (
	ErrRecordNotFound = errors.New("record not found")
	ErrEditConflict   = errors.New("edit conflict")
)
View Source
var AnonymousUser = &User{}
View Source
var (
	ErrDuplicateEmail = errors.New("duplicate email")
)

Functions

func ValidateChat

func ValidateChat(v *validator.Validator, chat *Chat, action int)

func ValidateContact

func ValidateContact(v *validator.Validator, contact *Contact, action int)

func ValidateEmail

func ValidateEmail(v *validator.Validator, email string)

func ValidateFilters

func ValidateFilters(v *validator.Validator, f Filters)

func ValidateMessage

func ValidateMessage(v *validator.Validator, message *Message, action int)

func ValidatePasswordPlaintext

func ValidatePasswordPlaintext(v *validator.Validator, password string)

func ValidatePhrase

func ValidatePhrase(v *validator.Validator, phrase *Phrase, action int)

func ValidateTokenPlaintext

func ValidateTokenPlaintext(v *validator.Validator, tokenPlaintext string)

func ValidateUser

func ValidateUser(v *validator.Validator, user *User)

Types

type Chat

type Chat struct {
	ID         int64     `json:"id" db:"id"`
	Name       string    `json:"name" db:"name"`
	ContactID  int64     `json:"contact_id" db:"contact_id"`
	Version    int32     `json:"version" db:"version"`
	CreatedAt  time.Time `json:"created_at" db:"created_at"`
	ModifiedAt time.Time `json:"modified_at" db:"modified_at"`
}

type ChatModel

type ChatModel struct {
	DB *sql.DB
}

func (ChatModel) Delete

func (m ChatModel) Delete(id int64) error

func (ChatModel) Get

func (m ChatModel) Get(id int64) (*Chat, error)

func (ChatModel) GetAll

func (m ChatModel) GetAll(name string, contact_id int64, filters Filters) ([]*Chat, Metadata, error)

func (ChatModel) Insert

func (m ChatModel) Insert(chat *Chat) error

func (ChatModel) Update

func (m ChatModel) Update(chat *Chat) error

type Contact

type Contact struct {
	ID          int64     `json:"id" db:"id"`
	Name        string    `json:"name" db:"name"`
	PhoneNumber string    `json:"phone_number" db:"phone_number"`
	Version     int32     `json:"version" db:"version"`
	CreatedAt   time.Time `json:"created_at" db:"created_at"`
	ModifiedAt  time.Time `json:"modified_at" db:"modified_at"`
}

type ContactModel

type ContactModel struct {
	DB *sql.DB
}

func (ContactModel) Delete

func (m ContactModel) Delete(id int64) error

func (ContactModel) Get

func (m ContactModel) Get(id int64) (*Contact, error)

func (ContactModel) GetAll

func (m ContactModel) GetAll(name string, phone_number string, filters Filters) ([]*Contact, Metadata, error)

func (ContactModel) Insert

func (m ContactModel) Insert(contact *Contact) error

func (ContactModel) Update

func (m ContactModel) Update(contact *Contact) error

type Filters

type Filters struct {
	Page         int
	PageSize     int
	Sort         string
	SortSafelist []string
}

type Message

type Message struct {
	ID                   int64     `json:"id" db:"id"`
	MessageDate          time.Time `json:"message_date" db:"message_date"`
	Message              string    `json:"message" db:"message"`
	ContactID            int64     `json:"contact_id" db:"contact_id"`
	Attachment           string    `json:"attachment" db:"attachment"`
	ChatID               int64     `json:"chat_id" db:"chat_id"`
	EnableSemanticSearch bool      `json:"enable_semantic_search" db:"enable_semantic_search"`
	Version              int32     `json:"version" db:"version"`
	CreatedAt            time.Time `json:"created_at" db:"created_at"`
	ModifiedAt           time.Time `json:"modified_at" db:"modified_at"`
}

type MessageModel

type MessageModel struct {
	DB *sql.DB
}

func (MessageModel) Delete

func (m MessageModel) Delete(id int64) error

func (MessageModel) Get

func (m MessageModel) Get(id int64) (*Message, error)

func (MessageModel) GetAll

func (m MessageModel) GetAll(filters Filters) ([]*Message, Metadata, error)

func (MessageModel) GetAllNotInSemantic

func (m MessageModel) GetAllNotInSemantic(filters Filters, contentField string) ([]*Message, Metadata, error)

not_in_semantic_start

func (MessageModel) Insert

func (m MessageModel) Insert(message *Message) error

func (MessageModel) Update

func (m MessageModel) Update(message *Message) error

type Metadata

type Metadata struct {
	CurrentPage  int `json:"current_page,omitempty"`
	PageSize     int `json:"page_size,omitempty"`
	FirstPage    int `json:"first_page,omitempty"`
	LastPage     int `json:"last_page,omitempty"`
	TotalRecords int `json:"total_records,omitempty"`
}

type Models

type Models struct {
	Contacts ContactModel
	Messages MessageModel
	Chats    ChatModel
	Phrases  PhraseModel
	Users    UserModel
	Tokens   TokenModel
}

func NewModels

func NewModels(db *sql.DB) Models

type Phrase

type Phrase struct {
	ID           int64     `json:"id" db:"id"`
	MessageID    int64     `json:"message_id" db:"message_id"`
	Title        string    `json:"title" db:"title"`
	Similarity   float64   `json:"similarity" db:"similarity"`
	Content      string    `json:"content" db:"content"`
	Tokens       int       `json:"tokens" db:"tokens"`
	Sequence     int       `json:"sequence" db:"sequence"`
	ContentField string    `json:"content_field" db:"content_field"`
	Version      int32     `json:"version" db:"version"`
	CreatedAt    time.Time `json:"created_at" db:"created_at"`
	ModifiedAt   time.Time `json:"modified_at" db:"modified_at"`
}

type PhraseModel

type PhraseModel struct {
	DB *sql.DB
}

func (PhraseModel) Delete

func (m PhraseModel) Delete(id int64) error

func (PhraseModel) Get

func (m PhraseModel) Get(id int64) (*Phrase, error)

func (PhraseModel) GetAll

func (m PhraseModel) GetAll(message_id int64, filters Filters) ([]*Phrase, Metadata, error)

func (PhraseModel) GetAllSemantic

func (m PhraseModel) GetAllSemantic(embedding pgvector.Vector, similarity float64, provider string, content_fields []string, message_id int64, filters Filters) ([]*Phrase, Metadata, error)

get_all_semantic_start

func (PhraseModel) GetAllWithoutEmbeddings

func (m PhraseModel) GetAllWithoutEmbeddings(limit int, provider string) ([]*Phrase, Metadata, error)

get_all_without_embeddings_start

func (PhraseModel) Insert

func (m PhraseModel) Insert(phrase *Phrase) error

func (PhraseModel) Update

func (m PhraseModel) Update(phrase *Phrase) error

func (PhraseModel) UpdateEmbedding

func (m PhraseModel) UpdateEmbedding(phrase *Phrase, embeddings pgvector.Vector, provider string) error

update_embedding_start

type Token

type Token struct {
	Plaintext string    `json:"token"`
	Hash      []byte    `json:"-"`
	UserID    int64     `json:"-"`
	Expiry    time.Time `json:"expiry"`
	Scope     string    `json:"-"`
}

type TokenModel

type TokenModel struct {
	DB *sql.DB
}

func (TokenModel) DeleteAllForUser

func (m TokenModel) DeleteAllForUser(scope string, userID int64) error

func (TokenModel) Insert

func (m TokenModel) Insert(token *Token) error

func (TokenModel) New

func (m TokenModel) New(userID int64, ttl time.Duration, scope string) (*Token, error)

type User

type User struct {
	ID        int64     `json:"id"`
	CreatedAt time.Time `json:"created_at"`
	Name      string    `json:"name"`
	Email     string    `json:"email"`
	Password  password  `json:"-"`
	Activated bool      `json:"activated"`
	Version   int       `json:"-"`
}

func (*User) IsAnonymous

func (u *User) IsAnonymous() bool

type UserModel

type UserModel struct {
	DB *sql.DB
}

func (UserModel) GetByEmail

func (m UserModel) GetByEmail(email string) (*User, error)

func (UserModel) GetForToken

func (m UserModel) GetForToken(tokenScope, tokenPlaintext string) (*User, error)

func (UserModel) Insert

func (m UserModel) Insert(user *User) error

func (UserModel) Update

func (m UserModel) Update(user *User) error

Jump to

Keyboard shortcuts

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