model

package
v0.0.0-...-27a526a Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Code generated by https://github.com/src-d/go-kallax. DO NOT EDIT. 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{
	Mention: &schemaMention{
		BaseSchema: kallax.NewBaseSchema(
			"mentions",
			"__mention",
			kallax.NewSchemaField("id"),
			kallax.ForeignKeys{},
			func() kallax.Record {
				return new(Mention)
			},
			false,
			kallax.NewSchemaField("id"),
			kallax.NewSchemaField("created_at"),
			kallax.NewSchemaField("updated_at"),
			kallax.NewSchemaField("endpoint"),
			kallax.NewSchemaField("aliases"),
			kallax.NewSchemaField("is_fork"),
			kallax.NewSchemaField("provider"),
			kallax.NewSchemaField("vcs"),
		),
		ID:        kallax.NewSchemaField("id"),
		CreatedAt: kallax.NewSchemaField("created_at"),
		UpdatedAt: kallax.NewSchemaField("updated_at"),
		Endpoint:  kallax.NewSchemaField("endpoint"),
		Aliases:   kallax.NewSchemaField("aliases"),
		IsFork:    kallax.NewSchemaField("is_fork"),
		Provider:  kallax.NewSchemaField("provider"),
		VCS:       kallax.NewSchemaField("vcs"),
	},
	Reference: &schemaReference{
		BaseSchema: kallax.NewBaseSchema(
			"repository_references",
			"__reference",
			kallax.NewSchemaField("id"),
			kallax.ForeignKeys{
				"Repository": kallax.NewForeignKey("repository_id", true),
			},
			func() kallax.Record {
				return new(Reference)
			},
			false,
			kallax.NewSchemaField("id"),
			kallax.NewSchemaField("created_at"),
			kallax.NewSchemaField("updated_at"),
			kallax.NewSchemaField("name"),
			kallax.NewSchemaField("repository_id"),
			kallax.NewSchemaField("hash"),
			kallax.NewSchemaField("init"),
			kallax.NewSchemaField("roots"),
			kallax.NewSchemaField("reference_time"),
		),
		ID:           kallax.NewSchemaField("id"),
		CreatedAt:    kallax.NewSchemaField("created_at"),
		UpdatedAt:    kallax.NewSchemaField("updated_at"),
		Name:         kallax.NewSchemaField("name"),
		RepositoryFK: kallax.NewSchemaField("repository_id"),
		Hash:         kallax.NewSchemaField("hash"),
		Init:         kallax.NewSchemaField("init"),
		Roots:        kallax.NewSchemaField("roots"),
		Time:         kallax.NewSchemaField("reference_time"),
	},
	Repository: &schemaRepository{
		BaseSchema: kallax.NewBaseSchema(
			"repositories",
			"__repository",
			kallax.NewSchemaField("id"),
			kallax.ForeignKeys{
				"References": kallax.NewForeignKey("repository_id", false),
			},
			func() kallax.Record {
				return new(Repository)
			},
			false,
			kallax.NewSchemaField("id"),
			kallax.NewSchemaField("created_at"),
			kallax.NewSchemaField("updated_at"),
			kallax.NewSchemaField("endpoints"),
			kallax.NewSchemaField("status"),
			kallax.NewSchemaField("fetched_at"),
			kallax.NewSchemaField("fetch_error_at"),
			kallax.NewSchemaField("last_commit_at"),
			kallax.NewSchemaField("is_fork"),
		),
		ID:           kallax.NewSchemaField("id"),
		CreatedAt:    kallax.NewSchemaField("created_at"),
		UpdatedAt:    kallax.NewSchemaField("updated_at"),
		Endpoints:    kallax.NewSchemaField("endpoints"),
		Status:       kallax.NewSchemaField("status"),
		FetchedAt:    kallax.NewSchemaField("fetched_at"),
		FetchErrorAt: kallax.NewSchemaField("fetch_error_at"),
		LastCommitAt: kallax.NewSchemaField("last_commit_at"),
		IsFork:       kallax.NewSchemaField("is_fork"),
	},
}

Functions

This section is empty.

Types

type FetchStatus

type FetchStatus string

FetchStatus represents the fetch status of this repository.

const (
	// NotFound means that the remote repository was not found at the given
	// endpoints.
	NotFound FetchStatus = "not_found"
	// Fetched means that the remote repository was found, fetched and
	// successfully stored.
	Fetched FetchStatus = "fetched"
	// Pending is the default value, meaning that the repository has not
	// been fetched yet.
	Pending FetchStatus = "pending"
	// Fetching means the remote repository was found and started being
	// fetched. It could also mean that there was an error and the repository
	// never finished fetching.
	Fetching FetchStatus = "fetching"
	// AuthRequired means the remote repository returns an authentication required
	// error when you try to fetch it. It doesn't mean that repository exists,
	// but if so, it cannot be processed without appropiate credentials.
	AuthRequired FetchStatus = "auth_req"
)

type Language

type Language string

Language represents a language name.

type Mention

type Mention struct {
	ID                kallax.ULID `pk:""`
	kallax.Model      `table:"mentions"`
	kallax.Timestamps `kallax:",inline"`
	// Endpoint is the repository URL as found.
	Endpoint string
	// Aliases are all the endpoints obtained from this mention. Endpoint field should be also included
	Aliases []string
	// IsFork is set to true if the repository is known to be fork. It is set to nil if the provider does not provide
	// this information at all. Note that false means that the repository is not a known fork to the provider, but it
	// might still be a fork, for example, a fork in GitHub from an original repository in Bitbucket.
	IsFork *bool
	// Provider is the repository provider (e.g. github).
	Provider string
	// VCS contains the version control system of this Mention.
	VCS VCS
}

Mention is the sighting of a remote repository online.

func NewMention

func NewMention() (record *Mention)

NewMention returns a new instance of Mention.

func (*Mention) ColumnAddress

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

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

func (*Mention) GetID

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

GetID returns the primary key of the model.

func (*Mention) NewRelationshipRecord

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

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

func (*Mention) SetRelationship

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

SetRelationship sets the given relationship in the given field.

func (*Mention) Value

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

Value returns the value of the given column.

type MentionQuery

type MentionQuery struct {
	*kallax.BaseQuery
}

MentionQuery is the object used to create queries for the Mention entity.

func NewMentionQuery

func NewMentionQuery() *MentionQuery

NewMentionQuery returns a new instance of MentionQuery.

func (*MentionQuery) BatchSize

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

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

func (*MentionQuery) Copy

func (q *MentionQuery) Copy() *MentionQuery

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 (*MentionQuery) FindByAliases

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

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 (*MentionQuery) FindByCreatedAt

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

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

func (*MentionQuery) FindByEndpoint

func (q *MentionQuery) FindByEndpoint(v string) *MentionQuery

FindByEndpoint adds a new filter to the query that will require that the Endpoint property is equal to the passed value.

func (*MentionQuery) FindByID

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

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 (*MentionQuery) FindByProvider

func (q *MentionQuery) FindByProvider(v string) *MentionQuery

FindByProvider adds a new filter to the query that will require that the Provider property is equal to the passed value.

func (*MentionQuery) FindByUpdatedAt

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

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

func (*MentionQuery) FindByVCS

func (q *MentionQuery) FindByVCS(v VCS) *MentionQuery

FindByVCS adds a new filter to the query that will require that the VCS property is equal to the passed value.

func (*MentionQuery) Limit

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

Limit sets the max number of items to retrieve.

func (*MentionQuery) Offset

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

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

func (*MentionQuery) Order

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

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

func (*MentionQuery) Select

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

Select adds columns to select in the query.

func (*MentionQuery) SelectNot

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

SelectNot excludes columns from being selected in the query.

func (*MentionQuery) Where

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

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

type MentionResultSet

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

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

func NewMentionResultSet

func NewMentionResultSet(rs kallax.ResultSet) *MentionResultSet

NewMentionResultSet creates a new result set for rows of the type Mention.

func (*MentionResultSet) All

func (rs *MentionResultSet) All() ([]*Mention, error)

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

func (*MentionResultSet) Close

func (rs *MentionResultSet) Close() error

Close closes the result set.

func (*MentionResultSet) Err

func (rs *MentionResultSet) Err() error

Err returns the last error occurred.

func (*MentionResultSet) ForEach

func (rs *MentionResultSet) ForEach(fn func(*Mention) 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 (*MentionResultSet) Get

func (rs *MentionResultSet) Get() (*Mention, error)

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

func (*MentionResultSet) Next

func (rs *MentionResultSet) 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 (*MentionResultSet) One

func (rs *MentionResultSet) One() (*Mention, error)

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

type MentionStore

type MentionStore struct {
	*kallax.Store
}

MentionStore is the entity to access the records of the type Mention in the database.

func NewMentionStore

func NewMentionStore(db *sql.DB) *MentionStore

NewMentionStore creates a new instance of MentionStore using a SQL database.

func (*MentionStore) Count

func (s *MentionStore) Count(q *MentionQuery) (int64, error)

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

func (*MentionStore) Debug

func (s *MentionStore) Debug() *MentionStore

Debug returns a new store that will print all SQL statements to stdout using the log.Printf function.

func (*MentionStore) DebugWith

func (s *MentionStore) DebugWith(logger kallax.LoggerFunc) *MentionStore

DebugWith returns a new store that will print all SQL statements using the given logger function.

func (*MentionStore) Delete

func (s *MentionStore) Delete(record *Mention) error

Delete removes the given record from the database.

func (*MentionStore) DisableCacher

func (s *MentionStore) DisableCacher() *MentionStore

DisableCacher turns off prepared statements, which can be useful in some scenarios.

func (*MentionStore) Find

Find returns the set of results for the given query.

func (*MentionStore) FindAll

func (s *MentionStore) FindAll(q *MentionQuery) ([]*Mention, error)

FindAll returns a list of all the rows returned by the given query.

func (*MentionStore) FindOne

func (s *MentionStore) FindOne(q *MentionQuery) (*Mention, error)

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

func (*MentionStore) GenericStore

func (s *MentionStore) GenericStore() *kallax.Store

GenericStore returns the generic store of this store.

func (*MentionStore) Insert

func (s *MentionStore) Insert(record *Mention) error

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

func (*MentionStore) MustCount

func (s *MentionStore) MustCount(q *MentionQuery) int64

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

func (*MentionStore) MustFind

func (s *MentionStore) MustFind(q *MentionQuery) *MentionResultSet

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

func (*MentionStore) MustFindOne

func (s *MentionStore) MustFindOne(q *MentionQuery) *Mention

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

func (*MentionStore) Reload

func (s *MentionStore) Reload(record *Mention) error

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

func (*MentionStore) Save

func (s *MentionStore) Save(record *Mention) (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 (*MentionStore) SetGenericStore

func (s *MentionStore) SetGenericStore(store *kallax.Store)

SetGenericStore changes the generic store of this store.

func (*MentionStore) Transaction

func (s *MentionStore) Transaction(callback func(*MentionStore) 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 (*MentionStore) Update

func (s *MentionStore) Update(record *Mention, 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 Reference

type Reference struct {
	ID                kallax.ULID `pk:""`
	kallax.Model      `table:"repository_references"`
	kallax.Timestamps `kallax:",inline"`
	// Name is the full reference name.
	Name string
	// Repository this reference belongs to.
	Repository *Repository `fk:",inverse"`
	// Hash is the hash of the reference.
	Hash SHA1
	// Init is the hash of the init commit reached from this reference.
	Init SHA1
	// Roots is a slice of the hashes of all root commits reachable from
	// this reference.
	Roots SHA1List
	// Time is the time of the commit this reference points too.
	Time time.Time `kallax:"reference_time"`
}

Reference is a reference of a repository as present in our repository storage.

func NewReference

func NewReference() (record *Reference)

NewReference returns a new instance of Reference.

func (*Reference) ColumnAddress

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

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

func (*Reference) GetID

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

GetID returns the primary key of the model.

func (*Reference) GitReference

func (r *Reference) GitReference() *plumbing.Reference

GitReference returns a git reference for this instance.

func (*Reference) NewRelationshipRecord

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

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

func (*Reference) SetRelationship

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

SetRelationship sets the given relationship in the given field.

func (*Reference) Value

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

Value returns the value of the given column.

type ReferenceQuery

type ReferenceQuery struct {
	*kallax.BaseQuery
}

ReferenceQuery is the object used to create queries for the Reference entity.

func NewReferenceQuery

func NewReferenceQuery() *ReferenceQuery

NewReferenceQuery returns a new instance of ReferenceQuery.

func (*ReferenceQuery) BatchSize

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

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

func (*ReferenceQuery) Copy

func (q *ReferenceQuery) Copy() *ReferenceQuery

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 (*ReferenceQuery) FindByCreatedAt

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

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

func (*ReferenceQuery) FindByHash

func (q *ReferenceQuery) FindByHash(v byte) *ReferenceQuery

FindByHash adds a new filter to the query that will require that the Hash property is equal to the passed value.

func (*ReferenceQuery) FindByID

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

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 (*ReferenceQuery) FindByInit

func (q *ReferenceQuery) FindByInit(v byte) *ReferenceQuery

FindByInit adds a new filter to the query that will require that the Init property is equal to the passed value.

func (*ReferenceQuery) FindByName

func (q *ReferenceQuery) FindByName(v string) *ReferenceQuery

FindByName adds a new filter to the query that will require that the Name property is equal to the passed value.

func (*ReferenceQuery) FindByRepository

func (q *ReferenceQuery) FindByRepository(v kallax.ULID) *ReferenceQuery

FindByRepository adds a new filter to the query that will require that the foreign key of Repository is equal to the passed value.

func (*ReferenceQuery) FindByTime

func (q *ReferenceQuery) FindByTime(cond kallax.ScalarCond, v time.Time) *ReferenceQuery

FindByTime adds a new filter to the query that will require that the Time property is equal to the passed value.

func (*ReferenceQuery) FindByUpdatedAt

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

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

func (*ReferenceQuery) Limit

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

Limit sets the max number of items to retrieve.

func (*ReferenceQuery) Offset

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

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

func (*ReferenceQuery) Order

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

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

func (*ReferenceQuery) Select

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

Select adds columns to select in the query.

func (*ReferenceQuery) SelectNot

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

SelectNot excludes columns from being selected in the query.

func (*ReferenceQuery) Where

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

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

func (*ReferenceQuery) WithRepository

func (q *ReferenceQuery) WithRepository() *ReferenceQuery

type ReferenceResultSet

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

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

func NewReferenceResultSet

func NewReferenceResultSet(rs kallax.ResultSet) *ReferenceResultSet

NewReferenceResultSet creates a new result set for rows of the type Reference.

func (*ReferenceResultSet) All

func (rs *ReferenceResultSet) All() ([]*Reference, error)

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

func (*ReferenceResultSet) Close

func (rs *ReferenceResultSet) Close() error

Close closes the result set.

func (*ReferenceResultSet) Err

func (rs *ReferenceResultSet) Err() error

Err returns the last error occurred.

func (*ReferenceResultSet) ForEach

func (rs *ReferenceResultSet) ForEach(fn func(*Reference) 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 (*ReferenceResultSet) Get

func (rs *ReferenceResultSet) Get() (*Reference, error)

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

func (*ReferenceResultSet) Next

func (rs *ReferenceResultSet) 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 (*ReferenceResultSet) One

func (rs *ReferenceResultSet) One() (*Reference, error)

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

type ReferenceStore

type ReferenceStore struct {
	*kallax.Store
}

ReferenceStore is the entity to access the records of the type Reference in the database.

func NewReferenceStore

func NewReferenceStore(db *sql.DB) *ReferenceStore

NewReferenceStore creates a new instance of ReferenceStore using a SQL database.

func (*ReferenceStore) Count

func (s *ReferenceStore) Count(q *ReferenceQuery) (int64, error)

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

func (*ReferenceStore) Debug

func (s *ReferenceStore) Debug() *ReferenceStore

Debug returns a new store that will print all SQL statements to stdout using the log.Printf function.

func (*ReferenceStore) DebugWith

func (s *ReferenceStore) DebugWith(logger kallax.LoggerFunc) *ReferenceStore

DebugWith returns a new store that will print all SQL statements using the given logger function.

func (*ReferenceStore) Delete

func (s *ReferenceStore) Delete(record *Reference) error

Delete removes the given record from the database.

func (*ReferenceStore) DisableCacher

func (s *ReferenceStore) DisableCacher() *ReferenceStore

DisableCacher turns off prepared statements, which can be useful in some scenarios.

func (*ReferenceStore) Find

Find returns the set of results for the given query.

func (*ReferenceStore) FindAll

func (s *ReferenceStore) FindAll(q *ReferenceQuery) ([]*Reference, error)

FindAll returns a list of all the rows returned by the given query.

func (*ReferenceStore) FindOne

func (s *ReferenceStore) FindOne(q *ReferenceQuery) (*Reference, error)

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

func (*ReferenceStore) GenericStore

func (s *ReferenceStore) GenericStore() *kallax.Store

GenericStore returns the generic store of this store.

func (*ReferenceStore) Insert

func (s *ReferenceStore) Insert(record *Reference) error

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

func (*ReferenceStore) MustCount

func (s *ReferenceStore) MustCount(q *ReferenceQuery) int64

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

func (*ReferenceStore) MustFind

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

func (*ReferenceStore) MustFindOne

func (s *ReferenceStore) MustFindOne(q *ReferenceQuery) *Reference

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

func (*ReferenceStore) Reload

func (s *ReferenceStore) Reload(record *Reference) error

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

func (*ReferenceStore) Save

func (s *ReferenceStore) Save(record *Reference) (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 (*ReferenceStore) SetGenericStore

func (s *ReferenceStore) SetGenericStore(store *kallax.Store)

SetGenericStore changes the generic store of this store.

func (*ReferenceStore) Transaction

func (s *ReferenceStore) Transaction(callback func(*ReferenceStore) 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 (*ReferenceStore) Update

func (s *ReferenceStore) Update(record *Reference, 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 Repository

type Repository struct {
	ID                kallax.ULID `pk:""`
	kallax.Model      `table:"repositories"`
	kallax.Timestamps `kallax:",inline"`
	// Endpoints is a slice of valid git endpoints to reach this repository.
	// For example, git://host/my/repo.git and https://host/my/repo.git.
	// They are meant to be endpoints of the same exact repository, and not
	// mirrors.
	Endpoints []string
	// Status is the fetch status of tge repository in our repository storage.
	Status FetchStatus
	// FetchedAt is the timestamp of the last time this repository was
	// fetched and archived in our repository storage successfully.
	FetchedAt *time.Time
	// FetchErrorAt is the timestamp of the last fetch error, if any.
	FetchErrorAt *time.Time
	// LastCommitAt is the last commit time found in this repository.
	LastCommitAt *time.Time
	// References is the current slice of references as present in our
	// repository storage.
	References []*Reference
	// IsFork stores if this repository is a fork or not. It can be nil if we don't know.
	IsFork *bool
}

Repository represents a remote repository found on the Internet.

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 RepositoryGroup

type RepositoryGroup struct {
	Label          string
	MainRepository kallax.ULID
	Repositories   []kallax.ULID
}

RepositoryGroup represents a set of repositories identified by a label with a main repository. For example, a repository and all its forks is a repository group with all forks as repositories and the original one as MainRepository.

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) 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) FindByEndpoints

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

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

func (*RepositoryQuery) FindByFetchErrorAt

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

FindByFetchErrorAt adds a new filter to the query that will require that the FetchErrorAt property is equal to the passed value.

func (*RepositoryQuery) FindByFetchedAt

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

FindByFetchedAt adds a new filter to the query that will require that the FetchedAt 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) FindByLastCommitAt

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

FindByLastCommitAt adds a new filter to the query that will require that the LastCommitAt property is equal to the passed value.

func (*RepositoryQuery) FindByStatus

func (q *RepositoryQuery) FindByStatus(v FetchStatus) *RepositoryQuery

FindByStatus adds a new filter to the query that will require that the Status 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

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

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

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

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

func (*RepositoryQuery) WithReferences

func (q *RepositoryQuery) WithReferences(cond kallax.Condition) *RepositoryQuery

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) Debug

func (s *RepositoryStore) Debug() *RepositoryStore

Debug returns a new store that will print all SQL statements to stdout using the log.Printf function.

func (*RepositoryStore) DebugWith

func (s *RepositoryStore) DebugWith(logger kallax.LoggerFunc) *RepositoryStore

DebugWith returns a new store that will print all SQL statements using the given logger function.

func (*RepositoryStore) Delete

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

Delete removes the given record from the database.

func (*RepositoryStore) DisableCacher

func (s *RepositoryStore) DisableCacher() *RepositoryStore

DisableCacher turns off prepared statements, which can be useful in some scenarios.

func (*RepositoryStore) Find

Find returns the set of results for the given query.

func (*RepositoryStore) FindAll

func (s *RepositoryStore) FindAll(q *RepositoryQuery) ([]*Repository, error)

FindAll returns a list of all the rows returned by 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) GenericStore

func (s *RepositoryStore) GenericStore() *kallax.Store

GenericStore returns the generic store of this store.

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) RemoveReferences

func (s *RepositoryStore) RemoveReferences(record *Repository, deleted ...*Reference) error

RemoveReferences removes the given items of the References field of the model. If no items are given, it removes all of them. The items will also be removed from the passed record inside this method. Note that is required that `References` is not empty. This method clears the the elements of References in a model, it does not retrieve them to know what relationships the model has.

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) SetGenericStore

func (s *RepositoryStore) SetGenericStore(store *kallax.Store)

SetGenericStore changes the generic store of this store.

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 SHA1

type SHA1 [20]byte

SHA1 is a SHA-1 hash.

func NewSHA1

func NewSHA1(s string) SHA1

func (*SHA1) Scan

func (h *SHA1) Scan(v interface{}) error

Scan assigns a value from a database driver.

func (SHA1) String

func (h SHA1) String() string

String representation from this SHA1

func (SHA1) Value

func (h SHA1) Value() (driver.Value, error)

Value returns a driver Value.

type SHA1List

type SHA1List []SHA1

SHA1List is a slice of SHA1 hashes. Use this instead of just []SHA1 because kallax will convert that to JSON and this implements its own methods to be stored as text[].

func (*SHA1List) Scan

func (h *SHA1List) Scan(v interface{}) error

Scan assigns a value from a database driver.

func (SHA1List) Value

func (h SHA1List) Value() (driver.Value, error)

Value returns a driver Value.

type VCS

type VCS string
const (
	// Git version control system
	GIT VCS = "git"
)

Jump to

Keyboard shortcuts

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