model

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: 14 Imported by: 0

Documentation

Overview

Package model contains the types for schema ...

Package model contains the types for schema ...

Index

Constants

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 GraphQLCountryAPIs = map[string]string{
	"Countries":                      "This is a graphQL resource Countries, have GetAll, Get, Insert, Update, Delete actions.",
	"Countries.CountryByCountryCode": "This is a graphQL resource Countries.CountryByCountryCode, only have NonPrimaryKeyGet action.",
	"Countries.CountryByCountryName": "This is a graphQL resource Countries.CountryByCountryName, only have NonPrimaryKeyGet action.",
}

GraphQLCountryAPIs specifies the GraphQL APIs for Country

View Source
var GraphQLCountryTypes = `` /* 1474-byte string literal not displayed */

GraphQLCountryTypes specifies the GraphQL types for Country

View Source
var LogCtx = loggerContext{}

DBCtx is the key for setting DB Context.WithValue

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

XOLog provides the log func used by generated queries.

Functions

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 CountAllCountry

func CountAllCountry(db XODB, queryArgs *CountryQueryArguments) (int, error)

CountAllCountry returns a count of all rows from 'country'

func DeleteCountryGraphQL

func DeleteCountryGraphQL(ctx context.Context, items []DeleteCountryInput) ([]graphql.ID, error)

DeleteCountryGraphQL is the GraphQL end point for DeleteCountry

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 GetCountryMutations

func GetCountryMutations() string

func GetCountryQueries

func GetCountryQueries() string

func GetResolverAPIs

func GetResolverAPIs(includeAPIs map[string]string, excludeAPIs []string) map[string]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 Log

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 Country

type Country struct {
	ID            int64          `json:"id" db:"id"`                         // id
	CountryName   string         `json:"country_name" db:"country_name"`     // country_name
	CountryActive sql.NullBool   `json:"country_active" db:"country_active"` // country_active
	CountrySnum   sql.NullInt64  `json:"country_snum" db:"country_snum"`     // country_snum
	CountryNum    sql.NullInt64  `json:"country_num" db:"country_num"`       // country_num
	CountryBnum   sql.NullInt64  `json:"country_bnum" db:"country_bnum"`     // country_bnum
	CreatedDate   pq.NullTime    `json:"created_date" db:"created_date"`     // created_date
	ChangedDate   pq.NullTime    `json:"changed_date" db:"changed_date"`     // changed_date
	DeletedDate   pq.NullTime    `json:"deleted_date" db:"deleted_date"`     // deleted_date
	CountryCode   string         `json:"country_code" db:"country_code"`     // country_code
	// contains filtered or unexported fields
}

Country represents a row from 'country'.

func CountryByCountryCode

func CountryByCountryCode(db XODB, countryCode string) (*Country, error)

CountryByCountryCode retrieves a row from 'country' as a Country.

Generated from index 'country_country_code_key'.

func CountryByCountryName

func CountryByCountryName(db XODB, countryName string) (*Country, error)

CountryByCountryName retrieves a row from 'country' as a Country.

Generated from index 'country_country_name_key'.

func CountryByID

func CountryByID(db XODB, id int64) (*Country, error)

CountryByID retrieves a row from 'country' as a Country.

Generated from index 'country_pk'.

func GetAllCountry

func GetAllCountry(db XODB, queryArgs *CountryQueryArguments) ([]*Country, error)

GetAllCountry returns all rows from 'country', based on the CountryQueryArguments. If the CountryQueryArguments is nil, it will use the default CountryQueryArguments instead.

func GetMostRecentChangedCountry

func GetMostRecentChangedCountry(db XODB, n int) ([]*Country, error)

GetMostRecentChangedCountry returns n most recent rows from 'country', ordered by "changed_date" in descending order.

func GetMostRecentCountry

func GetMostRecentCountry(db XODB, n int) ([]*Country, error)

GetMostRecentCountry returns n most recent rows from 'country', ordered by "created_date" in descending order.

func (*Country) Delete

func (c *Country) Delete(db XODB) error

Delete deletes the Country from the database.

func (*Country) Deleted

func (c *Country) Deleted() bool

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

func (*Country) Exists

func (c *Country) Exists() bool

Exists determines if the Country exists in the database.

func (*Country) Insert

func (c *Country) Insert(db XODB) error

Insert inserts the Country to the database.

func (*Country) Save

func (c *Country) Save(db XODB) error

Save saves the Country to the database.

func (*Country) Update

func (c *Country) Update(db XODB) error

Update updates the Country in the database.

func (*Country) Upsert

func (c *Country) Upsert(db XODB) error

Upsert performs an upsert for Country.

NOTE: PostgreSQL 9.5+ only

type CountryConnectionResolver

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

CountryConnectionResolver defines a GraphQL resolver for CountryConnection

func AllCountries

func AllCountries(ctx context.Context, queryArgs *CountryQueryArguments) (*CountryConnectionResolver, error)

AllCountries is the GraphQL end point for GetAllCountry

func NewCountryConnectionResolver

func NewCountryConnectionResolver(data []*Country, count int) *CountryConnectionResolver

func (CountryConnectionResolver) Countries

func (r CountryConnectionResolver) Countries() *[]*CountryResolver

Countries returns the list of Country

func (CountryConnectionResolver) Edges

Edges returns standard GraphQL edges

func (CountryConnectionResolver) PageInfo

PageInfo returns PageInfo

func (CountryConnectionResolver) TotalCount

func (r CountryConnectionResolver) TotalCount() *int32

TotalCount returns total count

type CountryEdgeResolver

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

CountryEdgeResolver defines the Country edge

func (CountryEdgeResolver) Cursor

func (r CountryEdgeResolver) Cursor() graphql.ID

Cursor returns the cursor

func (CountryEdgeResolver) Node

Node returns the Country node

type CountryFilter

type CountryFilter struct {
	Conjunction       *string // enum in "AND", "OR", nil(consider as single condition)
	CountryName       *string `json:"countryName"`        // equal to CountryName
	CountryNameLike   *string `json:"countryName_like"`   // LIKE
	CountryNameILike  *string `json:"countryName_ilike"`  // ILIKE case-insensitive
	CountryNameNLike  *string `json:"countryName_nlike"`  // NOT LIKE
	CountryNameNILike *string `json:"countryName_nilike"` // NOT ILIKE case-insensitive
	CountryCode       *string `json:"countryCode"`        // equal to CountryCode
	CountryCodeLike   *string `json:"countryCode_like"`   // LIKE
	CountryCodeILike  *string `json:"countryCode_ilike"`  // ILIKE case-insensitive
	CountryCodeNLike  *string `json:"countryCode_nlike"`  // NOT LIKE
	CountryCodeNILike *string `json:"countryCode_nilike"` // NOT ILIKE case-insensitive
}

CountryFilter related to CountryQueryArguments struct field name contain table column name in Camel style and logic operator(lt, gt etc) only indexed column and special column defined in ExtraFilters declared in file extra_rules.yaml

type CountryQueryArguments

type CountryQueryArguments struct {
	Cursor
	Where *CountryFilter
	// contains filtered or unexported fields
}

CountryQueryArguments composed by Cursor, CountryFilter and sql filter string

func ApplyCountryQueryArgsDefaults

func ApplyCountryQueryArgsDefaults(queryArgs *CountryQueryArguments) *CountryQueryArguments

ApplyCountryQueryArgsDefaults assigns default cursor values to non-nil fields.

type CountryResolver

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

CountryResolver defines the GraphQL resolver for 'Country'.

func CountryByCountryCodeGraphQL

func CountryByCountryCodeGraphQL(ctx context.Context, args struct {
	CountryCode string
}) (*CountryResolver, error)

CountryByCountryCodeGraphQL retrieves a row from 'country' as a Country.

Generated from index 'country_country_code_key'.

func CountryByCountryNameGraphQL

func CountryByCountryNameGraphQL(ctx context.Context, args struct {
	CountryName string
}) (*CountryResolver, error)

CountryByCountryNameGraphQL retrieves a row from 'country' as a Country.

Generated from index 'country_country_name_key'.

func CountryByIDGraphQL

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

CountryByIDGraphQL retrieves a row from 'country' as a Country.

Generated from index 'country_pk'.

func InsertCountryGraphQL

func InsertCountryGraphQL(ctx context.Context, items []InsertCountryInput) ([]CountryResolver, error)

InsertCountryGraphQL is the GraphQL end point for InsertCountry

func NewCountryResolver

func NewCountryResolver(node *Country) *CountryResolver

func UpdateCountryGraphQL

func UpdateCountryGraphQL(ctx context.Context, items []UpdateCountryInput) ([]CountryResolver, error)

UpdateCountryGraphQL is the GraphQL end point for UpdateCountry

func (CountryResolver) ChangedDate

func (r CountryResolver) ChangedDate() *graphql.Time

func (CountryResolver) CountryActive

func (r CountryResolver) CountryActive() *bool

func (CountryResolver) CountryBnum

func (r CountryResolver) CountryBnum() *string

func (CountryResolver) CountryCode

func (r CountryResolver) CountryCode() string
func (r CountryResolver) CountryLogo() *string

func (CountryResolver) CountryName

func (r CountryResolver) CountryName() string

func (CountryResolver) CountryNum

func (r CountryResolver) CountryNum() *string

func (CountryResolver) CountrySnum

func (r CountryResolver) CountrySnum() *string

func (CountryResolver) CreatedDate

func (r CountryResolver) CreatedDate() *graphql.Time

func (CountryResolver) DeletedDate

func (r CountryResolver) DeletedDate() *graphql.Time

func (CountryResolver) ID

func (r CountryResolver) 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 DeleteCountryInput

type DeleteCountryInput struct {
	ID graphql.ID
}

DeleteCountryInput defines the delete Country mutation input

type InsertCountryInput

type InsertCountryInput struct {
	CountryName   string
	CountryActive *bool
	CountrySnum   *string
	CountryNum    *string
	CountryBnum   *string
	CreatedDate   *graphql.Time
	ChangedDate   *graphql.Time
	DeletedDate   *graphql.Time
	CountryCode   string
}

InsertCountryInput defines the insert Country 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) AllCountries

func (RootResolver) CountryByCountryCode

func (RootResolver) CountryByCountryCode(ctx context.Context, args struct {
	CountryCode string
}) (*CountryResolver, error)

CountryByCountryCode generated by country_country_code_key

func (RootResolver) CountryByCountryName

func (RootResolver) CountryByCountryName(ctx context.Context, args struct {
	CountryName string
}) (*CountryResolver, error)

CountryByCountryName generated by country_country_name_key

func (RootResolver) CountryByID

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

CountryByID generated by country_pk

func (RootResolver) DeleteCountries

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

func (RootResolver) InsertCountries

func (RootResolver) InsertCountries(ctx context.Context, args struct{ Input []InsertCountryInput }) ([]CountryResolver, error)

func (RootResolver) UpdateCountries

func (RootResolver) UpdateCountries(ctx context.Context, args struct{ Input []UpdateCountryInput }) ([]CountryResolver, 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 UpdateCountryInput

type UpdateCountryInput struct {
	ID            graphql.ID
	CountryName   *string
	CountryActive *bool
	CountrySnum   *string
	CountryNum    *string
	CountryBnum   *string
	CreatedDate   *graphql.Time
	ChangedDate   *graphql.Time
	DeletedDate   *graphql.Time
	CountryCode   *string
	// contains filtered or unexported fields
}

UpdateCountryInput defines the update Country mutation input

type Verifier

type Verifier interface {
	VerifyAC(ctx context.Context, resourceID, action string, args interface{}) error
	VerifyRefAC(ctx context.Context, resourceID, action string, args interface{}) error
}

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 'public'.

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