sqruct: github.com/oov/sqruct/cmd/sqruct/example/mdl Index | Files

package mdl

import "github.com/oov/sqruct/cmd/sqruct/example/mdl"

Index

Package Files

zzaccount.go zzpost.go zzposttag.go zztag.go

type Account Uses

type Account struct {
    ID   int64  `mdl:"pk,notnull,uniq,default,autoincr"`
    Name string `mdl:"notnull,uniq"`
}

Account represents the following table.

CREATE TABLE "account"(
	"id" INTEGER PRIMARY KEY AUTOINCREMENT,
	"name" VARCHAR(30) NOT NULL UNIQUE
);

func GetAccount Uses

func GetAccount(db sqruct.DB, id int64) (*Account, error)

func (*Account) Delete Uses

func (t *Account) Delete(db sqruct.DB) error

func (*Account) Insert Uses

func (t *Account) Insert(db sqruct.DB) error

func (*Account) SelectPost Uses

func (t *Account) SelectPost(db sqruct.DB) ([]Post, error)

func (*Account) Update Uses

func (t *Account) Update(db sqruct.DB) error

type Post Uses

type Post struct {
    ID        int64     `mdl:"pk,notnull,uniq,default,autoincr"`
    AccountID int64     `mdl:"fk,notnull"`
    At        time.Time `mdl:"notnull"`
    Message   string    `mdl:"notnull"`
}

Post represents the following table.

CREATE TABLE "post"(
	"id" INTEGER PRIMARY KEY,
	"accountid" INTEGER NOT NULL,
	"at" DATETIME NOT NULL,
	"message" VARCHAR(8125) NOT NULL,
	FOREIGN KEY (accountid) REFERENCES account(id) ON DELETE CASCADE
);

func GetPost Uses

func GetPost(db sqruct.DB, id int64) (*Post, error)

func (*Post) Delete Uses

func (t *Post) Delete(db sqruct.DB) error

func (*Post) GetAccount Uses

func (t *Post) GetAccount(db sqruct.DB) (*Account, error)

func (*Post) Insert Uses

func (t *Post) Insert(db sqruct.DB) error

func (*Post) SelectPostTag Uses

func (t *Post) SelectPostTag(db sqruct.DB) ([]PostTag, error)

func (*Post) SelectTag Uses

func (t *Post) SelectTag(db sqruct.DB) ([]Tag, []PostTag, error)

func (*Post) Update Uses

func (t *Post) Update(db sqruct.DB) error

type PostTag Uses

type PostTag struct {
    PostID int64 `mdl:"fk,notnull"`
    TagID  int64 `mdl:"fk,notnull"`
}

PostTag represents the following table.

CREATE TABLE "posttag"(
	"postid" INTEGER NOT NULL,
	"tagid" INTEGER NOT NULL,
	FOREIGN KEY (postid) REFERENCES post(id) ON DELETE CASCADE,
	FOREIGN KEY (tagid) REFERENCES tag(id) ON DELETE CASCADE,
	PRIMARY KEY (postid, tagid)
);

func GetPostTag Uses

func GetPostTag(db sqruct.DB, postID int64, tagID int64) (*PostTag, error)

func (*PostTag) Delete Uses

func (t *PostTag) Delete(db sqruct.DB) error

func (*PostTag) GetPost Uses

func (t *PostTag) GetPost(db sqruct.DB) (*Post, error)

func (*PostTag) GetTag Uses

func (t *PostTag) GetTag(db sqruct.DB) (*Tag, error)

func (*PostTag) Insert Uses

func (t *PostTag) Insert(db sqruct.DB) error

func (*PostTag) Update Uses

func (t *PostTag) Update(db sqruct.DB) error

type Tag Uses

type Tag struct {
    ID   int64  `mdl:"pk,notnull,uniq,default,autoincr"`
    Name string `mdl:"notnull,uniq"`
}

Tag represents the following table.

CREATE TABLE "tag"(
	"id" INTEGER PRIMARY KEY,
	"name" VARCHAR(30) NOT NULL UNIQUE
);

func GetTag Uses

func GetTag(db sqruct.DB, id int64) (*Tag, error)

func (*Tag) Delete Uses

func (t *Tag) Delete(db sqruct.DB) error

func (*Tag) Insert Uses

func (t *Tag) Insert(db sqruct.DB) error

func (*Tag) SelectPost Uses

func (t *Tag) SelectPost(db sqruct.DB) ([]Post, []PostTag, error)

func (*Tag) SelectPostTag Uses

func (t *Tag) SelectPostTag(db sqruct.DB) ([]PostTag, error)

func (*Tag) Update Uses

func (t *Tag) Update(db sqruct.DB) error

Package mdl imports 3 packages (graph). Updated 2016-08-01. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).