package
1.0.51
Repository: https://github.com/mutablelogic/go-sqlite.git
Documentation: pkg.go.dev

# README

sqlite3 objects (SQObjects)

This package provides a method forwriting, reading and deleting go objects (structures) to and from SQLite databases. Not exactly a full "Object Relational Database" but a way to reduce the amount of boilerplate code and error handling need to keep a database in syncronization with objects.

This package is part of a wider project, github.com/mutablelogic/go-sqlite. Please see the module documentation for more information.

The general method is:

  1. Use tags on your struct definition to define the database table, columns, indexes and foreign keys;
  2. Create a database connection and register the structs you want to use to syncronize with the database. You also need to register foreign key relationships;
  3. Create the tables and indexes in the database;
  4. Read, write and delete objects using the Read, Write and Delete methods. You may need to use some hook functions to handle foreign key relationships.

For example, the following definition:

type Doc struct {
	A int    `sqlite:"a,autoincrement"`
	B int    `sqlite:"b,unique"`
	C string `sqlite:"c"`
}

Will create a table with the following statement:

CREATE TABLE IF NOT EXISTS main.doc (
  a INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  b INTEGER,
  c TEXT,
  UNIQUE (b)
)

A fuller explanation of the tags and supported types is provided below. SQObjects is currently in development.

Introduction

TODO

Registering a definition

TODO

Supported scalar types

TODO

Writing objects (inserting and updating)

TODO

Reading objects (selecting)

TODO

Deleting objects

TODO

# Functions

DeclType returns the declared column type for a given field uses TEXT by default.
MustRegisterClass registers a SQObject class, panics if an error occurs.
MustRegisterView registers a SQObject view class, panics if an error occurs.
MustRegisterVirtual registers a SQObject virtual table class, panics if an error occurs.
Return a reflection object for the given struct or nil if the argument is not a pointer to a struct or has no fields which are exported.
RegisterClass registers a SQObject class, returns the class and any errors.
RegisterView registers a SQObject view class, returns the class and any errors.
RegisterVirtual registers a SQObject virtual table class, returns the class and any errors.
ValueOf returns a struct value or nil if not valid.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author