Documentation ¶
Overview ¶
Package litedoc provides a document database that uses SQLite as it's storage engine.
Index ¶
- type Collection
- type Database
- type Document
- func (d *Document) Create(ctx context.Context, doc any) error
- func (d *Document) DataTo(doc any) error
- func (d *Document) Delete(ctx context.Context) error
- func (d *Document) Get(ctx context.Context, doc any) error
- func (d *Document) Set(ctx context.Context, doc any) error
- func (d *Document) UnmarshalJSON(data []byte) error
- type Op
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collection ¶
type Collection struct { ID string // contains filtered or unexported fields }
Collection represents the top level structure that holds Documents.
func (*Collection) Document ¶
func (c *Collection) Document(id string) *Document
Document returns a reference to a Document within the Collection.
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database holds the underlying SQLite database connection.
func (*Database) Collection ¶
func (db *Database) Collection(id string) *Collection
Collection returns a reference to a database collection.
type Document ¶
type Document struct { ID string // contains filtered or unexported fields }
Document represents a JSON document stored in a Collection.
func (*Document) Create ¶
Create will create a new Document with the doc type within the Collection it references creating the Collection if it does not already exist. The Document is stored as it's JSON encoded format.
func (*Document) DataTo ¶
DataTo unmarshals the JSON data into the doc type if the JSON data exists.
func (*Document) Get ¶
Get will find a single Document by it's ID and call DataTo for you to decode the JSON into the doc's type.
func (*Document) Set ¶
Set will update a Document with the doc type within the Collection it references creating the Collection if it does not already exist. Set will fail if the Document does not already exist in the database. Create should be used first.