bookshare-backend-api: github.com/misrab/bookshare-backend-api/models Index | Files

package models

import "github.com/misrab/bookshare-backend-api/models"

Index

Package Files

post.go reading.go setup.go user.go user_reading.go

func ConnectDB Uses

func ConnectDB() *gorp.DbMap

func SetupDB Uses

func SetupDB() *gorp.DbMap

func SetupDB() *sql.DB {

type Post Uses

type Post struct {
    Comment string `json:"comment"`

    // Associations
    UserId    int64 `json:"user_id" db:"user_id"`
    ReadingId int64 `json:"reading_id" db:"reading_id"`

    // default 0 means public innit
    Private bool `json:"private" db:"private"`

    // Meta
    Id        int64 `db:"id" json:"id"`
    CreatedAt int64 `db:"created_at" json:"created_at"`
    UpdatedAt int64 `db:"updated_at" json:"updated_at"`
}

func (*Post) PreInsert Uses

func (i *Post) PreInsert(s gorp.SqlExecutor) error

implement the PreInsert and PreUpdate hooks

func (*Post) PreUpdate Uses

func (i *Post) PreUpdate(s gorp.SqlExecutor) error

type Reading Uses

type Reading struct {

    // subject_times
    // subjects
    Title string `json:"title"`

    // OL key e.g. "/works/OL10000223W"
    Key string `json:"key"`

    // cover ids e.g. [3140972]
    // get at http://covers.openlibrary.org/b/id/{id}-[S|M|L].jpg
    Cover int `json:"cover"` //db:"covers,size:1024"

    // our extra fields
    IsBook bool `json:"is_book"`

    // Meta
    Id        int64 `db:"id" json:"id"`
    CreatedAt int64 `db:"created_at" json:"created_at"`
    UpdatedAt int64 `db:"updated_at" json:"updated_at"`
}

func (*Reading) PreInsert Uses

func (i *Reading) PreInsert(s gorp.SqlExecutor) error

implement the PreInsert and PreUpdate hooks

func (*Reading) PreUpdate Uses

func (i *Reading) PreUpdate(s gorp.SqlExecutor) error

type User Uses

type User struct {
    Id  int64 `db:"id" json:"id"`

    Email string `json:"email"` //`schema:"email",json:"email",db:"email"`
    Hash  string `json:"hash"`

    CreatedAt int64 `db:"created_at" json:"created_at"`
    UpdatedAt int64 `db:"updated_at" json:"updated_at"`
}

func (*User) ComparePassword Uses

func (user *User) ComparePassword(password string) error

Returns nil error on sucess

func (*User) PreInsert Uses

func (i *User) PreInsert(s gorp.SqlExecutor) error

implement the PreInsert and PreUpdate hooks

func (*User) PreUpdate Uses

func (i *User) PreUpdate(s gorp.SqlExecutor) error

func (*User) SetPassword Uses

func (user *User) SetPassword(password string)

type UserReading Uses

type UserReading struct {
    UserId    int64 `db:"user_id"`
    ReadingId int64 `db:"reading_id"`

    // Meta
    Id        int64 `db:"id"`
    CreatedAt int64 `db:"created_at"`
    UpdatedAt int64 `db:"updated_at"`
}

join table

func (*UserReading) PreInsert Uses

func (i *UserReading) PreInsert(s gorp.SqlExecutor) error

implement the PreInsert and PreUpdate hooks

func (*UserReading) PreUpdate Uses

func (i *UserReading) PreUpdate(s gorp.SqlExecutor) error

Package models imports 9 packages (graph) and is imported by 3 packages. Updated 2016-08-03. Refresh now. Tools for package owners.