sqlite

package
v0.0.0-...-ae79bc6 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

---------------------------------------------------------------------------------------------- // -- Copyright (c) 2024 Braden Hitchcock - MIT License (https://opensource.org/licenses/MIT) -- // ---------------------------------------------------------------------------------------------- //

---------------------------------------------------------------------------------------------- // -- Copyright (c) 2024 Braden Hitchcock - MIT License (https://opensource.org/licenses/MIT) -- // ---------------------------------------------------------------------------------------------- //

---------------------------------------------------------------------------------------------- // -- Copyright (c) 2024 Braden Hitchcock - MIT License (https://opensource.org/licenses/MIT) -- // ---------------------------------------------------------------------------------------------- //

---------------------------------------------------------------------------------------------- // -- Copyright (c) 2024 Braden Hitchcock - MIT License (https://opensource.org/licenses/MIT) -- // ---------------------------------------------------------------------------------------------- //

---------------------------------------------------------------------------------------------- // -- Copyright (c) 2024 Braden Hitchcock - MIT License (https://opensource.org/licenses/MIT) -- // ---------------------------------------------------------------------------------------------- //

---------------------------------------------------------------------------------------------- // -- Copyright (c) 2024 Braden Hitchcock - MIT License (https://opensource.org/licenses/MIT) -- // ---------------------------------------------------------------------------------------------- //

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

func Open(path string) (*sql.DB, error)

Open creates a new connection to an SQLite database on the filesystem at the provided path and initializes it with settings needed to support the various stores.

The returned DB handle is safe to use throughout the lifetime of the program and by multiple goroutines; therefore, Open should only be called once when the program starts.

Types

type ConversationStore

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

func NewConversationStore

func NewConversationStore(db *sql.DB) (ConversationStore, error)

func (ConversationStore) AddConversationEntity

func (s ConversationStore) AddConversationEntity(
	ctx context.Context, e store.ConversationEntity,
) error

func (ConversationStore) GetConversationEntity

func (s ConversationStore) GetConversationEntity(
	ctx context.Context, id model.Uuid,
) (store.ConversationEntity, error)

func (ConversationStore) ListConversationEntities

func (s ConversationStore) ListConversationEntities(
	ctx context.Context,
) ([]store.ConversationEntity, error)

func (ConversationStore) RemoveConversationEntity

func (s ConversationStore) RemoveConversationEntity(ctx context.Context, id model.Uuid) error

func (ConversationStore) UpdateConversationEntity

func (s ConversationStore) UpdateConversationEntity(
	ctx context.Context, e store.ConversationEntity,
) error

type EncryptedDataAccessor

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

func NewEncryptedDataAccessor

func NewEncryptedDataAccessor(table string, dkey crypto.Key) EncryptedDataAccessor

func (*EncryptedDataAccessor) Decrypt

func (e *EncryptedDataAccessor) Decrypt(d []byte) ([]byte, error)

func (*EncryptedDataAccessor) Encrypt

func (e *EncryptedDataAccessor) Encrypt(d []byte) ([]byte, error)

func (*EncryptedDataAccessor) Get

func (e *EncryptedDataAccessor) Get(
	ctx context.Context, db QueryExecutor, id model.Uuid,
) ([]byte, error)

func (*EncryptedDataAccessor) GetByIdHash

func (e *EncryptedDataAccessor) GetByIdHash(
	ctx context.Context, db QueryExecutor, h crypto.DataHash,
) ([]byte, error)

func (*EncryptedDataAccessor) GetList

func (e *EncryptedDataAccessor) GetList(ctx context.Context, db QueryExecutor) ([][]byte, error)

func (*EncryptedDataAccessor) GetListFilt

func (e *EncryptedDataAccessor) GetListFilt(
	ctx context.Context, db QueryExecutor, pred map[string]any,
) ([][]byte, error)

func (*EncryptedDataAccessor) Set

func (e *EncryptedDataAccessor) Set(
	ctx context.Context, db QueryExecutor, id model.Uuid, v []byte,
) error

func (*EncryptedDataAccessor) SetWithIdHash

func (e *EncryptedDataAccessor) SetWithIdHash(
	ctx context.Context, db QueryExecutor, id model.Uuid, h crypto.DataHash, v []byte,
) error

type GroupStore

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

func NewGroupStore

func NewGroupStore(db *sql.DB) (GroupStore, error)

func (GroupStore) AddGroupEntity

func (s GroupStore) AddGroupEntity(ctx context.Context, e store.GroupEntity) error

func (GroupStore) GetGroupEntity

func (s GroupStore) GetGroupEntity(ctx context.Context) (store.GroupEntity, error)

func (GroupStore) IsGroupDataSet

func (s GroupStore) IsGroupDataSet(ctx context.Context) (bool, error)

func (GroupStore) UpdateGroupEntity

func (s GroupStore) UpdateGroupEntity(ctx context.Context, e store.GroupEntity) error

type MemberStore

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

func NewMemberStore

func NewMemberStore(db *sql.DB) (MemberStore, error)

func (MemberStore) AddMemberEntity

func (s MemberStore) AddMemberEntity(ctx context.Context, e store.MemberEntity) error

func (MemberStore) GetMemberEntity

func (s MemberStore) GetMemberEntity(
	ctx context.Context, id model.Uuid,
) (store.MemberEntity, error)

func (MemberStore) GetMemberEntityByUname

func (s MemberStore) GetMemberEntityByUname(
	ctx context.Context, uhash crypto.DataHash,
) (store.MemberEntity, error)

func (MemberStore) ListMemberEntities

func (s MemberStore) ListMemberEntities(ctx context.Context) ([]store.MemberEntity, error)

func (MemberStore) RemoveMemberEntity

func (s MemberStore) RemoveMemberEntity(ctx context.Context, id model.Uuid) error

func (MemberStore) UpdateMemberEntity

func (s MemberStore) UpdateMemberEntity(ctx context.Context, e store.MemberEntity) error

type MessageStore

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

func NewMessageStore

func NewMessageStore(db *sql.DB) (MessageStore, error)

func (MessageStore) AddMessageEntity

func (s MessageStore) AddMessageEntity(ctx context.Context, e store.MessageEntity) error

func (MessageStore) GetMessageEntity

func (s MessageStore) GetMessageEntity(
	ctx context.Context, id model.Uuid,
) (store.MessageEntity, error)

func (MessageStore) ListMessageEntities

func (s MessageStore) ListMessageEntities(
	ctx context.Context, cid model.Uuid, q store.ListMessageDataQuery,
) ([]store.MessageEntity, error)

func (MessageStore) RemoveMessageEntity

func (s MessageStore) RemoveMessageEntity(ctx context.Context, id model.Uuid) error

func (MessageStore) UpdateMessageEntity

func (s MessageStore) UpdateMessageEntity(
	ctx context.Context, e store.MessageEntity,
) error

type QueryExecutor

type QueryExecutor interface {
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
	QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
	QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
}

Jump to

Keyboard shortcuts

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