model

package
v2.6.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2018 License: GPL-3.0 Imports: 5 Imported by: 1

Documentation

Overview

IMPORTANT! This is auto generated code by https://github.com/src-d/go-kallax Please, do not touch the code below, and if you do, do it under your own risk. Take into account that all the code you write here will be completely erased from earth the next time you generate the kallax models.

Index

Constants

This section is empty.

Variables

View Source
var Schema = &schema{
	Repository: &schemaRepository{
		BaseSchema: kallax.NewBaseSchema(
			"cgit",
			"__repository",
			kallax.NewSchemaField("id"),
			kallax.ForeignKeys{},
			func() kallax.Record {
				return new(Repository)
			},
			false,
			kallax.NewSchemaField("id"),
			kallax.NewSchemaField("created_at"),
			kallax.NewSchemaField("updated_at"),
			kallax.NewSchemaField("cgit_url"),
			kallax.NewSchemaField("url"),
			kallax.NewSchemaField("aliases"),
			kallax.NewSchemaField("html"),
		),
		ID:        kallax.NewSchemaField("id"),
		CreatedAt: kallax.NewSchemaField("created_at"),
		UpdatedAt: kallax.NewSchemaField("updated_at"),
		CgitURL:   kallax.NewSchemaField("cgit_url"),
		URL:       kallax.NewSchemaField("url"),
		Aliases:   kallax.NewSchemaField("aliases"),
		HTML:      kallax.NewSchemaField("html"),
	},
	URL: &schemaURL{
		BaseSchema: kallax.NewBaseSchema(
			"cgit_urls",
			"__url",
			kallax.NewSchemaField("id"),
			kallax.ForeignKeys{},
			func() kallax.Record {
				return new(URL)
			},
			false,
			kallax.NewSchemaField("id"),
			kallax.NewSchemaField("created_at"),
			kallax.NewSchemaField("updated_at"),
			kallax.NewSchemaField("cgit_url"),
		),
		ID:        kallax.NewSchemaField("id"),
		CreatedAt: kallax.NewSchemaField("created_at"),
		UpdatedAt: kallax.NewSchemaField("updated_at"),
		CgitUrl:   kallax.NewSchemaField("cgit_url"),
	},
}

Functions

This section is empty.

Types

type Repository

type Repository struct {
	ID                kallax.ULID `pk:""`
	kallax.Model      `table:"cgit"`
	kallax.Timestamps `kallax:",inline"`

	CgitURL string
	URL     string
	Aliases []string
	HTML    string
}

func NewRepository

func NewRepository() (record *Repository)

NewRepository returns a new instance of Repository.

func (*Repository) ColumnAddress

func (r *Repository) ColumnAddress(col string) (interface{}, error)

ColumnAddress returns the pointer to the value of the given column.

func (*Repository) GetID

func (r *Repository) GetID() kallax.Identifier

GetID returns the primary key of the model.

func (*Repository) NewRelationshipRecord

func (r *Repository) NewRelationshipRecord(field string) (kallax.Record, error)

NewRelationshipRecord returns a new record for the relatiobship in the given field.

func (*Repository) SetRelationship

func (r *Repository) SetRelationship(field string, rel interface{}) error

SetRelationship sets the given relationship in the given field.

func (*Repository) Value

func (r *Repository) Value(col string) (interface{}, error)

Value returns the value of the given column.

type RepositoryQuery

type RepositoryQuery struct {
	*kallax.BaseQuery
}

RepositoryQuery is the object used to create queries for the Repository entity.

func NewRepositoryQuery

func NewRepositoryQuery() *RepositoryQuery

NewRepositoryQuery returns a new instance of RepositoryQuery.

func (*RepositoryQuery) BatchSize

func (q *RepositoryQuery) BatchSize(size uint64) *RepositoryQuery

BatchSize sets the number of items to fetch per batch when there are 1:N relationships selected in the query.

func (*RepositoryQuery) Copy

func (q *RepositoryQuery) Copy() *RepositoryQuery

Copy returns a new identical copy of the query. Remember queries are mutable so make a copy any time you need to reuse them.

func (*RepositoryQuery) FindByAliases

func (q *RepositoryQuery) FindByAliases(v ...string) *RepositoryQuery

FindByAliases adds a new filter to the query that will require that the Aliases property contains all the passed values; if no passed values, it will do nothing

func (*RepositoryQuery) FindByCgitURL

func (q *RepositoryQuery) FindByCgitURL(v string) *RepositoryQuery

FindByCgitURL adds a new filter to the query that will require that the CgitURL property is equal to the passed value

func (*RepositoryQuery) FindByCreatedAt

func (q *RepositoryQuery) FindByCreatedAt(cond kallax.ScalarCond, v time.Time) *RepositoryQuery

FindByCreatedAt adds a new filter to the query that will require that the CreatedAt property is equal to the passed value

func (*RepositoryQuery) FindByHTML

func (q *RepositoryQuery) FindByHTML(v string) *RepositoryQuery

FindByHTML adds a new filter to the query that will require that the HTML property is equal to the passed value

func (*RepositoryQuery) FindByID

func (q *RepositoryQuery) FindByID(v ...kallax.ULID) *RepositoryQuery

FindByID adds a new filter to the query that will require that the ID property is equal to one of the passed values; if no passed values, it will do nothing

func (*RepositoryQuery) FindByURL

func (q *RepositoryQuery) FindByURL(v string) *RepositoryQuery

FindByURL adds a new filter to the query that will require that the URL property is equal to the passed value

func (*RepositoryQuery) FindByUpdatedAt

func (q *RepositoryQuery) FindByUpdatedAt(cond kallax.ScalarCond, v time.Time) *RepositoryQuery

FindByUpdatedAt adds a new filter to the query that will require that the UpdatedAt property is equal to the passed value

func (*RepositoryQuery) Limit

func (q *RepositoryQuery) Limit(n uint64) *RepositoryQuery

Limit sets the max number of items to retrieve.

func (*RepositoryQuery) Offset

func (q *RepositoryQuery) Offset(n uint64) *RepositoryQuery

Offset sets the number of items to skip from the result set of items.

func (*RepositoryQuery) Order

Order adds order clauses to the query for the given columns.

func (*RepositoryQuery) Select

func (q *RepositoryQuery) Select(columns ...kallax.SchemaField) *RepositoryQuery

Select adds columns to select in the query.

func (*RepositoryQuery) SelectNot

func (q *RepositoryQuery) SelectNot(columns ...kallax.SchemaField) *RepositoryQuery

SelectNot excludes columns from being selected in the query.

func (*RepositoryQuery) Where

Where adds a condition to the query. All conditions added are concatenated using a logical AND.

type RepositoryResultSet

type RepositoryResultSet struct {
	ResultSet kallax.ResultSet
	// contains filtered or unexported fields
}

RepositoryResultSet is the set of results returned by a query to the database.

func NewRepositoryResultSet

func NewRepositoryResultSet(rs kallax.ResultSet) *RepositoryResultSet

NewRepositoryResultSet creates a new result set for rows of the type Repository.

func (*RepositoryResultSet) All

func (rs *RepositoryResultSet) All() ([]*Repository, error)

All returns all records on the result set and closes the result set.

func (*RepositoryResultSet) Close

func (rs *RepositoryResultSet) Close() error

Close closes the result set.

func (*RepositoryResultSet) Err

func (rs *RepositoryResultSet) Err() error

Err returns the last error occurred.

func (*RepositoryResultSet) ForEach

func (rs *RepositoryResultSet) ForEach(fn func(*Repository) error) error

ForEach iterates over the complete result set passing every record found to the given callback. It is possible to stop the iteration by returning `kallax.ErrStop` in the callback. Result set is always closed at the end.

func (*RepositoryResultSet) Get

func (rs *RepositoryResultSet) Get() (*Repository, error)

Get retrieves the last fetched item from the result set and the last error.

func (*RepositoryResultSet) Next

func (rs *RepositoryResultSet) Next() bool

Next fetches the next item in the result set and returns true if there is a next item. The result set is closed automatically when there are no more items.

func (*RepositoryResultSet) One

func (rs *RepositoryResultSet) One() (*Repository, error)

One returns the first record on the result set and closes the result set.

type RepositoryStore

type RepositoryStore struct {
	*kallax.Store
}

RepositoryStore is the entity to access the records of the type Repository in the database.

func NewRepositoryStore

func NewRepositoryStore(db *sql.DB) *RepositoryStore

NewRepositoryStore creates a new instance of RepositoryStore using a SQL database.

func (*RepositoryStore) Count

func (s *RepositoryStore) Count(q *RepositoryQuery) (int64, error)

Count returns the number of rows that would be retrieved with the given query.

func (*RepositoryStore) Delete

func (s *RepositoryStore) Delete(record *Repository) error

Delete removes the given record from the database.

func (*RepositoryStore) Find

Find returns the set of results for the given query.

func (*RepositoryStore) FindOne

func (s *RepositoryStore) FindOne(q *RepositoryQuery) (*Repository, error)

FindOne returns the first row returned by the given query. `ErrNotFound` is returned if there are no results.

func (*RepositoryStore) Insert

func (s *RepositoryStore) Insert(record *Repository) error

Insert inserts a Repository in the database. A non-persisted object is required for this operation.

func (*RepositoryStore) MustCount

func (s *RepositoryStore) MustCount(q *RepositoryQuery) int64

MustCount returns the number of rows that would be retrieved with the given query, but panics if there is an error.

func (*RepositoryStore) MustFind

MustFind returns the set of results for the given query, but panics if there is any error.

func (*RepositoryStore) MustFindOne

func (s *RepositoryStore) MustFindOne(q *RepositoryQuery) *Repository

MustFindOne returns the first row retrieved by the given query. It panics if there is an error or if there are no rows.

func (*RepositoryStore) Reload

func (s *RepositoryStore) Reload(record *Repository) error

Reload refreshes the Repository with the data in the database and makes it writable.

func (*RepositoryStore) Save

func (s *RepositoryStore) Save(record *Repository) (updated bool, err error)

Save inserts the object if the record is not persisted, otherwise it updates it. Same rules of Update and Insert apply depending on the case.

func (*RepositoryStore) Transaction

func (s *RepositoryStore) Transaction(callback func(*RepositoryStore) error) error

Transaction executes the given callback in a transaction and rollbacks if an error is returned. The transaction is only open in the store passed as a parameter to the callback.

func (*RepositoryStore) Update

func (s *RepositoryStore) Update(record *Repository, cols ...kallax.SchemaField) (updated int64, err error)

Update updates the given record on the database. If the columns are given, only these columns will be updated. Otherwise all of them will be. Be very careful with this, as you will have a potentially different object in memory but not on the database. Only writable records can be updated. Writable objects are those that have been just inserted or retrieved using a query with no custom select fields.

type URL

type URL struct {
	ID                kallax.ULID `pk:""`
	kallax.Model      `table:"cgit_urls"`
	kallax.Timestamps `kallax:",inline"`

	CgitUrl string
}

func NewURL

func NewURL() (record *URL)

NewURL returns a new instance of URL.

func (*URL) ColumnAddress

func (r *URL) ColumnAddress(col string) (interface{}, error)

ColumnAddress returns the pointer to the value of the given column.

func (*URL) GetID

func (r *URL) GetID() kallax.Identifier

GetID returns the primary key of the model.

func (*URL) NewRelationshipRecord

func (r *URL) NewRelationshipRecord(field string) (kallax.Record, error)

NewRelationshipRecord returns a new record for the relatiobship in the given field.

func (*URL) SetRelationship

func (r *URL) SetRelationship(field string, rel interface{}) error

SetRelationship sets the given relationship in the given field.

func (*URL) Value

func (r *URL) Value(col string) (interface{}, error)

Value returns the value of the given column.

type URLQuery

type URLQuery struct {
	*kallax.BaseQuery
}

URLQuery is the object used to create queries for the URL entity.

func NewURLQuery

func NewURLQuery() *URLQuery

NewURLQuery returns a new instance of URLQuery.

func (*URLQuery) BatchSize

func (q *URLQuery) BatchSize(size uint64) *URLQuery

BatchSize sets the number of items to fetch per batch when there are 1:N relationships selected in the query.

func (*URLQuery) Copy

func (q *URLQuery) Copy() *URLQuery

Copy returns a new identical copy of the query. Remember queries are mutable so make a copy any time you need to reuse them.

func (*URLQuery) FindByCgitUrl

func (q *URLQuery) FindByCgitUrl(v string) *URLQuery

FindByCgitUrl adds a new filter to the query that will require that the CgitUrl property is equal to the passed value

func (*URLQuery) FindByCreatedAt

func (q *URLQuery) FindByCreatedAt(cond kallax.ScalarCond, v time.Time) *URLQuery

FindByCreatedAt adds a new filter to the query that will require that the CreatedAt property is equal to the passed value

func (*URLQuery) FindByID

func (q *URLQuery) FindByID(v ...kallax.ULID) *URLQuery

FindByID adds a new filter to the query that will require that the ID property is equal to one of the passed values; if no passed values, it will do nothing

func (*URLQuery) FindByUpdatedAt

func (q *URLQuery) FindByUpdatedAt(cond kallax.ScalarCond, v time.Time) *URLQuery

FindByUpdatedAt adds a new filter to the query that will require that the UpdatedAt property is equal to the passed value

func (*URLQuery) Limit

func (q *URLQuery) Limit(n uint64) *URLQuery

Limit sets the max number of items to retrieve.

func (*URLQuery) Offset

func (q *URLQuery) Offset(n uint64) *URLQuery

Offset sets the number of items to skip from the result set of items.

func (*URLQuery) Order

func (q *URLQuery) Order(cols ...kallax.ColumnOrder) *URLQuery

Order adds order clauses to the query for the given columns.

func (*URLQuery) Select

func (q *URLQuery) Select(columns ...kallax.SchemaField) *URLQuery

Select adds columns to select in the query.

func (*URLQuery) SelectNot

func (q *URLQuery) SelectNot(columns ...kallax.SchemaField) *URLQuery

SelectNot excludes columns from being selected in the query.

func (*URLQuery) Where

func (q *URLQuery) Where(cond kallax.Condition) *URLQuery

Where adds a condition to the query. All conditions added are concatenated using a logical AND.

type URLResultSet

type URLResultSet struct {
	ResultSet kallax.ResultSet
	// contains filtered or unexported fields
}

URLResultSet is the set of results returned by a query to the database.

func NewURLResultSet

func NewURLResultSet(rs kallax.ResultSet) *URLResultSet

NewURLResultSet creates a new result set for rows of the type URL.

func (*URLResultSet) All

func (rs *URLResultSet) All() ([]*URL, error)

All returns all records on the result set and closes the result set.

func (*URLResultSet) Close

func (rs *URLResultSet) Close() error

Close closes the result set.

func (*URLResultSet) Err

func (rs *URLResultSet) Err() error

Err returns the last error occurred.

func (*URLResultSet) ForEach

func (rs *URLResultSet) ForEach(fn func(*URL) error) error

ForEach iterates over the complete result set passing every record found to the given callback. It is possible to stop the iteration by returning `kallax.ErrStop` in the callback. Result set is always closed at the end.

func (*URLResultSet) Get

func (rs *URLResultSet) Get() (*URL, error)

Get retrieves the last fetched item from the result set and the last error.

func (*URLResultSet) Next

func (rs *URLResultSet) Next() bool

Next fetches the next item in the result set and returns true if there is a next item. The result set is closed automatically when there are no more items.

func (*URLResultSet) One

func (rs *URLResultSet) One() (*URL, error)

One returns the first record on the result set and closes the result set.

type URLStore

type URLStore struct {
	*kallax.Store
}

URLStore is the entity to access the records of the type URL in the database.

func NewURLStore

func NewURLStore(db *sql.DB) *URLStore

NewURLStore creates a new instance of URLStore using a SQL database.

func (*URLStore) Count

func (s *URLStore) Count(q *URLQuery) (int64, error)

Count returns the number of rows that would be retrieved with the given query.

func (*URLStore) Delete

func (s *URLStore) Delete(record *URL) error

Delete removes the given record from the database.

func (*URLStore) Find

func (s *URLStore) Find(q *URLQuery) (*URLResultSet, error)

Find returns the set of results for the given query.

func (*URLStore) FindOne

func (s *URLStore) FindOne(q *URLQuery) (*URL, error)

FindOne returns the first row returned by the given query. `ErrNotFound` is returned if there are no results.

func (*URLStore) Insert

func (s *URLStore) Insert(record *URL) error

Insert inserts a URL in the database. A non-persisted object is required for this operation.

func (*URLStore) MustCount

func (s *URLStore) MustCount(q *URLQuery) int64

MustCount returns the number of rows that would be retrieved with the given query, but panics if there is an error.

func (*URLStore) MustFind

func (s *URLStore) MustFind(q *URLQuery) *URLResultSet

MustFind returns the set of results for the given query, but panics if there is any error.

func (*URLStore) MustFindOne

func (s *URLStore) MustFindOne(q *URLQuery) *URL

MustFindOne returns the first row retrieved by the given query. It panics if there is an error or if there are no rows.

func (*URLStore) Reload

func (s *URLStore) Reload(record *URL) error

Reload refreshes the URL with the data in the database and makes it writable.

func (*URLStore) Save

func (s *URLStore) Save(record *URL) (updated bool, err error)

Save inserts the object if the record is not persisted, otherwise it updates it. Same rules of Update and Insert apply depending on the case.

func (*URLStore) Transaction

func (s *URLStore) Transaction(callback func(*URLStore) error) error

Transaction executes the given callback in a transaction and rollbacks if an error is returned. The transaction is only open in the store passed as a parameter to the callback.

func (*URLStore) Update

func (s *URLStore) Update(record *URL, cols ...kallax.SchemaField) (updated int64, err error)

Update updates the given record on the database. If the columns are given, only these columns will be updated. Otherwise all of them will be. Be very careful with this, as you will have a potentially different object in memory but not on the database. Only writable records can be updated. Writable objects are those that have been just inserted or retrieved using a query with no custom select fields.

Jump to

Keyboard shortcuts

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