models

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package models contains the types for schema 'luoji'.

Package models contains the types for schema 'luoji'.

Index

Constants

View Source
const GraphQLAccountTypes = `` /* 525-byte string literal not displayed */

GraphQLAccountTypes specifies the GraphQL types for Account

View Source
const GraphQLCommonTypes = `` /* 159-byte string literal not displayed */

GraphQL related types

Variables

View Source
var DBCtx = dbContext{}

DBCtx is the key for setting DB Context.WithValue

View Source
var DefaultCursor = Cursor{
	Offset: &defaultOffset,
	Limit:  &defaultLimit,
	Index:  &defaultIndex,
	Desc:   &defaultDesc,
	Dead:   &defaultDead,
}

DefaultCursor will get the 50 first non-deleted IDs from a table.

View Source
var XOLog = func(string, ...interface{}) {}

XOLog provides the log func used by generated queries.

Functions

func AccountsByBalanceGraphQL

func AccountsByBalanceGraphQL(ctx context.Context, args struct {
	Balance *float64
}) (*[]AccountResolver, error)

AccountsByBalanceGraphQL retrieves a row from 'accounts' as a Account.

Generated from index 'balance_idx'.

func Bool

func Bool(b bool) sql.NullBool

Bool returns a nullable bool.

func BoolPointer

func BoolPointer(b *bool) sql.NullBool

BoolPointer converts bool pointer to sql.NullBool

func CountAllAccount

func CountAllAccount(db XODB, queryArgs *AccountQueryArguments) (int, error)

CountAllAccount returns a count of all rows from 'luoji.accounts'

func DeleteAccountGraphQL

func DeleteAccountGraphQL(ctx context.Context, items []DeleteAccountInput) ([]graphql.ID, error)

DeleteAccountGraphQL is the GraphQL end point for DeleteAccount

func Float64

func Float64(i float64) sql.NullFloat64

Float64 returns a nullable float64

func Float64Pointer

func Float64Pointer(i *float64) sql.NullFloat64

Float64Pointer converts a float64 pointer to sql.NullFloat64

func GetAccountMutations

func GetAccountMutations() string

func GetAccountQueries

func GetAccountQueries() string

func GetRootSchema

func GetRootSchema(extraQueries, extraMutations, extraTypes string) string

func Int64

func Int64(i int64) sql.NullInt64

Int64 returns a nullable int64

func Int64Pointer

func Int64Pointer(i *int64) sql.NullInt64

Int64Pointer converts a int64 pointer to sql.NullInt64

func PointerBool

func PointerBool(b sql.NullBool) *bool

PointerBool converts bool to pointer to bool

func PointerFloat64

func PointerFloat64(i sql.NullFloat64) *float64

PointerFloat64 converts sql.NullFloat64 to pointer to float64

func PointerFloat64SqlFloat64

func PointerFloat64SqlFloat64(i sql.NullFloat64) *float64

PointerFloat64SqlFloat64 converts sql.NullFloat64 pointer to graphql.ID pointer

func PointerGqlTime

func PointerGqlTime(t pq.NullTime) *graphql.Time

PointerGqlTime converts pq.NullType to pointer to graphql.Time

func PointerInt64

func PointerInt64(i sql.NullInt64) *int64

PointerInt64 converts sql.NullInt64 to pointer to int64

func PointerString

func PointerString(s sql.NullString) *string

PointerString converts sql.NullString to pointer to string

func PointerStringFloat64

func PointerStringFloat64(i *float64) *string

PointerStringFloat64 converts Float64 pointer to string pointer

func PointerStringInt64

func PointerStringInt64(i *int64) *string

PointerStringInt64 converts Int64 pointer to string pointer

func PointerStringSqlInt64

func PointerStringSqlInt64(i sql.NullInt64) *string

PointerStringSqlInt64 converts sql.NullInt64 pointer to graphql.ID pointer

func PointerTime

func PointerTime(t pq.NullTime) *time.Time

PointerTime converts pq.NullTIme to pointer to time.Time

func String

func String(s string) sql.NullString

String returns a nullable string

func StringPointer

func StringPointer(s *string) sql.NullString

StringPointer converts string pointer to sql.NullString

func Time

func Time(t time.Time) pq.NullTime

Time returns a nullable Time

func TimeGqlPointer

func TimeGqlPointer(t *graphql.Time) pq.NullTime

TimeGqlPointer converts graphql.Time pointer to pq.NullTime

func TimePointer

func TimePointer(t *time.Time) pq.NullTime

TimePointer converts time.Time pointer to pq.NullTime

Types

type Account

type Account struct {
	ID      int64           `json:"id" db:"id"`           // id
	Balance sql.NullFloat64 `json:"balance" db:"balance"` // balance
	// contains filtered or unexported fields
}

Account represents a row from 'accounts'.

func AccountByID

func AccountByID(db XODB, id int64) (*Account, error)

AccountByID retrieves a row from 'accounts' as a Account.

Generated from index 'primary'.

func AccountsByBalance

func AccountsByBalance(db XODB, balance sql.NullFloat64) ([]*Account, error)

AccountsByBalance retrieves a row from 'accounts' as a Account.

Generated from index 'balance_idx'.

func GetAllAccount

func GetAllAccount(db XODB, queryArgs *AccountQueryArguments) ([]*Account, error)

GetAllAccount returns all rows from 'luoji.accounts', based on the AccountQueryArguments. If the AccountQueryArguments is nil, it will use the default AccountQueryArguments instead.

func GetMostRecentAccount

func GetMostRecentAccount(db XODB, n int) ([]*Account, error)

GetMostRecentAccount returns n most recent rows from 'luoji.accounts', ordered by "created_date" in descending order.

func GetMostRecentChangedAccount

func GetMostRecentChangedAccount(db XODB, n int) ([]*Account, error)

GetMostRecentChangedAccount returns n most recent rows from 'luoji.accounts', ordered by "changed_date" in descending order.

func (*Account) Delete

func (a *Account) Delete(db XODB) error

Delete deletes the Account from the database.

func (*Account) Deleted

func (a *Account) Deleted() bool

Deleted provides information if the Account has been deleted from the database.

func (*Account) Exists

func (a *Account) Exists() bool

Exists determines if the Account exists in the database.

func (*Account) Insert

func (a *Account) Insert(db XODB) error

Insert inserts the Account to the database.

func (*Account) Save

func (a *Account) Save(db XODB) error

Save saves the Account to the database.

func (*Account) Update

func (a *Account) Update(db XODB) error

Update updates the Account in the database.

func (*Account) Upsert

func (a *Account) Upsert(db XODB) error

Upsert performs an upsert for Account.

NOTE: PostgreSQL 9.5+ only

type AccountConnectionResolver

type AccountConnectionResolver struct {
	// contains filtered or unexported fields
}

AccountConnectionResolver defines a GraphQL resolver for AccountConnection

func AllAccounts

func AllAccounts(ctx context.Context, queryArgs *AccountQueryArguments) (*AccountConnectionResolver, error)

AllAccounts is the GraphQL end point for GetAllAccount

func (AccountConnectionResolver) Accounts

func (r AccountConnectionResolver) Accounts() *[]*AccountResolver

Accounts returns the list of Account

func (AccountConnectionResolver) Edges

Edges returns standard GraphQL edges

func (AccountConnectionResolver) PageInfo

PageInfo returns PageInfo

func (AccountConnectionResolver) TotalCount

func (r AccountConnectionResolver) TotalCount() *int32

TotalCount returns total count

type AccountEdgeResolver

type AccountEdgeResolver struct {
	// contains filtered or unexported fields
}

AccountEdgeResolver defines the Account edge

func (AccountEdgeResolver) Cursor

func (r AccountEdgeResolver) Cursor() graphql.ID

Cursor returns the cursor

func (AccountEdgeResolver) Node

Node returns the Account node

type AccountFilter

type AccountFilter struct {
	Conjunction *string  // enum in "AND", "OR", nil(consider as single condition)
	Balance     *float64 `json:"balance"`     // equal to Balance
	BalanceLt   *float64 `json:"balance_lt"`  // less than Balance
	BalanceLte  *float64 `json:"balance_lte"` // less than and equal to Balance
	BalanceGt   *float64 `json:"balance_gt"`  // greater than Balance
	BalanceGte  *float64 `json:"balance_gte"` // greater than and equal to Balance
}

AccountFilter related to AccountQueryArguments struct field name contain table column name in Camel style and logic operator(lt, gt etc) only indexed column and special column defined in sqlSpecColFilterCtlMap declared in file xo/internal/funcs.go

type AccountQueryArguments

type AccountQueryArguments struct {
	Cursor
	Where *AccountFilter
	// contains filtered or unexported fields
}

AccountQueryArguments composed by Cursor, AccountFilter and sql filter string

func ApplyAccountQueryArgsDefaults

func ApplyAccountQueryArgsDefaults(queryArgs *AccountQueryArguments) *AccountQueryArguments

ApplyAccountQueryArgsDefaults assigns default cursor values to non-nil fields.

type AccountResolver

type AccountResolver struct {
	// contains filtered or unexported fields
}

AccountResolver defines the GraphQL resolver for 'Account'.

func AccountByIDGraphQL

func AccountByIDGraphQL(ctx context.Context, args struct {
	ID graphql.ID
}) (*AccountResolver, error)

AccountByIDGraphQL retrieves a row from 'accounts' as a Account.

Generated from index 'primary'.

func InsertAccountGraphQL

func InsertAccountGraphQL(ctx context.Context, items []InsertAccountInput) ([]AccountResolver, error)

InsertAccountGraphQL is the GraphQL end point for InsertAccount

func NewAccountResolver

func NewAccountResolver(node *Account) *AccountResolver

func UpdateAccountGraphQL

func UpdateAccountGraphQL(ctx context.Context, items []UpdateAccountInput) ([]AccountResolver, error)

UpdateAccountGraphQL is the GraphQL end point for UpdateAccount

func (AccountResolver) Balance

func (r AccountResolver) Balance() *float64

func (AccountResolver) ID

func (r AccountResolver) ID() graphql.ID

type Cursor

type Cursor struct {
	Offset *int32
	Limit  *int32
	Index  *string
	Desc   *bool
	Dead   *bool
	After  *graphql.ID
	First  *int32
	Before *graphql.ID
	Last   *int32
}

Cursor specifies an index to sort by, the direction of the sort, an offset, and a limit.

type DeleteAccountInput

type DeleteAccountInput struct {
	ID graphql.ID
}

DeleteAccountInput defines the delete Account mutation input

type InsertAccountInput

type InsertAccountInput struct {
	Balance *float64
}

InsertAccountInput defines the insert Account mutation input

type PageInfoResolver

type PageInfoResolver struct {
	// contains filtered or unexported fields
}

PageInfoResolver defines the GraphQL PageInfo type

func (PageInfoResolver) EndCursor

func (r PageInfoResolver) EndCursor() *graphql.ID

EndCursor returns the end cursor (global id)

func (PageInfoResolver) HasNextPage

func (r PageInfoResolver) HasNextPage() bool

HasNextPage returns if next page is available

func (PageInfoResolver) HasPreviousPage

func (r PageInfoResolver) HasPreviousPage() bool

HasPreviousPage returns if previous page is available

func (PageInfoResolver) StartCursor

func (r PageInfoResolver) StartCursor() *graphql.ID

StartCursor returns the start cursor (global id)

type RootResolver

type RootResolver struct{}

func (RootResolver) AccountByID

func (RootResolver) AccountByID(ctx context.Context, args struct {
	ID graphql.ID
}) (*AccountResolver, error)

AccountByID generated by primary

func (RootResolver) AccountsByBalance

func (RootResolver) AccountsByBalance(ctx context.Context, args struct {
	Balance *float64
}) (*[]AccountResolver, error)

AccountsByBalance generated by balance_idx

func (RootResolver) AllAccounts

func (RootResolver) DeleteAccounts

func (RootResolver) DeleteAccounts(ctx context.Context, args struct{ Input []DeleteAccountInput }) ([]graphql.ID, error)

func (RootResolver) InsertAccounts

func (RootResolver) InsertAccounts(ctx context.Context, args struct{ Input []InsertAccountInput }) ([]AccountResolver, error)

func (RootResolver) UpdateAccounts

func (RootResolver) UpdateAccounts(ctx context.Context, args struct{ Input []UpdateAccountInput }) ([]AccountResolver, error)

type ScannerValuer

type ScannerValuer interface {
	sql.Scanner
	driver.Valuer
}

ScannerValuer is the common interface for types that implement both the database/sql.Scanner and sql/driver.Valuer interfaces.

type Slice

type Slice []ScannerValuer

Slice is a slice of ScannerValuers.

type StringSlice

type StringSlice []string

StringSlice is a slice of strings.

func (*StringSlice) Scan

func (ss *StringSlice) Scan(src interface{}) error

Scan satisfies the sql.Scanner interface for StringSlice.

func (StringSlice) Value

func (ss StringSlice) Value() (driver.Value, error)

Value satisfies the driver.Valuer interface for StringSlice.

type UpdateAccountInput

type UpdateAccountInput struct {
	ID      graphql.ID
	Balance *float64
}

UpdateAccountInput defines the update Account mutation input

type XODB

type XODB interface {
	Exec(string, ...interface{}) (sql.Result, error)
	Query(string, ...interface{}) (*sql.Rows, error)
	QueryRow(string, ...interface{}) *sql.Row
}

XODB is the common interface for database operations that can be used with types from schema 'luoji'.

This should work with database/sql.DB and database/sql.Tx.

Jump to

Keyboard shortcuts

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