geostore

package module
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: MIT Imports: 11 Imported by: 0

README

Geo Store Open in Gitpod

tests Go Report Card PkgGoDev

Usage:

store, err := NewStore(NewStoreOptions{
  DB:                 db,
  CountryTableName:   "geo_country",
  StateTableName:     "geo_state",
  TimezoneTableName:  "geo_timezone",
  AutomigrateEnabled: true,
})

if err != nil {
  t.Fatal("unexpected error:", err)
}

if store == nil {
  t.Fatal("unexpected nil store")
}

country, errFind := store.CountryFindByIso2("BG")

if errFind != nil {
  t.Fatal("unexpected error:", errFind)
}

if country == nil {
  t.Fatal("Country MUST NOT be nil")
}

log.Print(country.Name()) // Prints the name of the country

Documentation

Index

Constants

View Source
const COLUMN_CONTINENT = "continent"
View Source
const COLUMN_COUNTRY_CODE = "country_code"
View Source
const COLUMN_CREATED_AT = "created_at"
View Source
const COLUMN_DELETED_AT = "deleted_at"
View Source
const COLUMN_GLOBAL_NAME = "global_name"
View Source
const COLUMN_ID = "id"
View Source
const COLUMN_ISO2_CODE = "iso2_code"
View Source
const COLUMN_ISO3_CODE = "iso3_code"
View Source
const COLUMN_NAME = "name"
View Source
const COLUMN_OFFSET = "offset"
View Source
const COLUMN_PHONE_PREFIX = "phone_prefix"
View Source
const COLUMN_STATE_CODE = "state_code"
View Source
const COLUMN_STATUS = "status"
View Source
const COLUMN_TIMEZONE = "timezone"
View Source
const COLUMN_UPDATED_AT = "updated_at"
View Source
const COLUMN_ZONE_NAME = "zone_name"
View Source
const COUNTRY_STATUS_ACTIVE = "active"
View Source
const COUNTRY_STATUS_INACTIVE = "inactive"
View Source
const STATE_STATUS_ACTIVE = "active"
View Source
const STATE_STATUS_INACTIVE = "inactive"
View Source
const TIMEZONE_STATUS_ACTIVE = "active"
View Source
const TIMEZONE_STATUS_INACTIVE = "inactive"

Variables

This section is empty.

Functions

This section is empty.

Types

type Country

type Country struct {
	dataobject.DataObject
}

func NewCountry

func NewCountry() *Country

func NewCountryFromExistingData

func NewCountryFromExistingData(data map[string]string) *Country

func (*Country) Continent

func (o *Country) Continent() string

func (*Country) CreatedAt

func (o *Country) CreatedAt() string

func (*Country) DeletedAt

func (o *Country) DeletedAt() string

func (*Country) IsoCode2

func (o *Country) IsoCode2() string

func (*Country) IsoCode3

func (o *Country) IsoCode3() string

func (*Country) Name

func (o *Country) Name() string

func (*Country) PhonePrefix

func (o *Country) PhonePrefix() string

func (*Country) SetContinent

func (o *Country) SetContinent(continent string) *Country

func (*Country) SetCreatedAt

func (o *Country) SetCreatedAt(createdAt string) *Country

func (*Country) SetDeletedAt

func (o *Country) SetDeletedAt(deletedAt string) *Country

func (*Country) SetIsoCode2

func (o *Country) SetIsoCode2(isoCode2 string) *Country

func (*Country) SetIsoCode3

func (o *Country) SetIsoCode3(isoCode3 string) *Country

func (*Country) SetName

func (o *Country) SetName(name string) *Country

func (*Country) SetPhonePrefix

func (o *Country) SetPhonePrefix(phonePrefix string) *Country

func (*Country) SetStatus

func (o *Country) SetStatus(status string) *Country

func (*Country) SetUpdatedAt

func (o *Country) SetUpdatedAt(updatedAt string) *Country

func (*Country) Status

func (o *Country) Status() string

func (*Country) UpdatedAt

func (o *Country) UpdatedAt() string

type CountryQueryOptions

type CountryQueryOptions struct {
	ID          string
	IDIn        []string
	Status      string
	StatusIn    []string
	Iso2        string
	Iso3        string
	Offset      int
	Limit       int
	SortOrder   string
	OrderBy     string
	CountOnly   bool
	WithDeleted bool
}

type NewStoreOptions

type NewStoreOptions struct {
	DB                 *sql.DB
	DbDriverName       string
	CountryTableName   string
	StateTableName     string
	TimezoneTableName  string
	AutomigrateEnabled bool
}

type State added in v0.6.0

type State struct {
	dataobject.DataObject
}

func NewState added in v0.6.0

func NewState() *State

func NewStateFromExistingData added in v0.6.0

func NewStateFromExistingData(data map[string]string) *State

func (*State) CountryCode added in v0.6.0

func (o *State) CountryCode() string

func (*State) CreatedAt added in v0.6.0

func (o *State) CreatedAt() string

func (*State) DeletedAt added in v0.6.0

func (o *State) DeletedAt() string

func (*State) Name added in v0.6.0

func (o *State) Name() string

func (*State) SetCountryCode added in v0.6.0

func (o *State) SetCountryCode(countryCodeIso2 string) *State

func (*State) SetCreatedAt added in v0.6.0

func (o *State) SetCreatedAt(createdAt string) *State

func (*State) SetDeletedAt added in v0.6.0

func (o *State) SetDeletedAt(deletedAt string) *State

func (*State) SetName added in v0.6.0

func (o *State) SetName(name string) *State

func (*State) SetStateCode added in v0.6.0

func (o *State) SetStateCode(stateCode string) *State

func (*State) SetStatus added in v0.6.0

func (o *State) SetStatus(status string) *State

func (*State) SetUpdatedAt added in v0.6.0

func (o *State) SetUpdatedAt(updatedAt string) *State

func (*State) StateCode added in v0.6.0

func (o *State) StateCode() string

func (*State) Status added in v0.6.0

func (o *State) Status() string

func (*State) UpdatedAt added in v0.6.0

func (o *State) UpdatedAt() string

type StateQueryOptions added in v0.6.0

type StateQueryOptions struct {
	ID          string
	Status      string
	StatusIn    []string
	CountryCode string
	StateCode   string
	Offset      int
	Limit       int
	SortOrder   string
	OrderBy     string
	CountOnly   bool
	WithDeleted bool
}

type Store

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

func NewStore

func NewStore(options NewStoreOptions) (*Store, error)

func (*Store) AutoMigrate

func (store *Store) AutoMigrate() error

AutoMigrate auto migrate

func (*Store) CountryCreate

func (store *Store) CountryCreate(country *Country) error

func (*Store) CountryDelete

func (store *Store) CountryDelete(country *Country) error

func (*Store) CountryDeleteByID

func (store *Store) CountryDeleteByID(id string) error

func (*Store) CountryFindByID

func (store *Store) CountryFindByID(id string) (*Country, error)

func (*Store) CountryFindByIso2

func (store *Store) CountryFindByIso2(iso2Code string) (*Country, error)

func (*Store) CountryList

func (store *Store) CountryList(options CountryQueryOptions) ([]Country, error)

func (*Store) CountryNameFindByIso2 added in v0.5.0

func (store *Store) CountryNameFindByIso2(iso2Code string) (string, error)

func (*Store) CountrySoftDelete

func (store *Store) CountrySoftDelete(country *Country) error

func (*Store) CountrySoftDeleteByID

func (store *Store) CountrySoftDeleteByID(id string) error

func (*Store) CountryUpdate

func (store *Store) CountryUpdate(country *Country) error

func (*Store) EnableDebug

func (st *Store) EnableDebug(debug bool)

EnableDebug - enables the debug option

func (*Store) StateCreate added in v0.6.0

func (store *Store) StateCreate(state *State) error

func (*Store) StateList added in v0.6.0

func (store *Store) StateList(options StateQueryOptions) ([]State, error)

func (*Store) TimezoneCreate

func (store *Store) TimezoneCreate(timezone *Timezone) error

func (*Store) TimezoneList

func (store *Store) TimezoneList(options TimezoneQueryOptions) ([]Timezone, error)

type StoreInterface

type StoreInterface interface {
	CountryCreate(country *Country) error
	CountryDelete(country *Country) error
	CountryDeleteByID(countryID string) error
	CountryFindByID(countryID string) (*Country, error)
	CountryFindByIso2(iso2Code string) (*Country, error)
	CountryList(options CountryQueryOptions) ([]Country, error)
	CountrySoftDelete(discount *Country) error
	CountrySoftDeleteByID(discountID string) error
	CountryUpdate(country *Country) error
	TimezoneCreate(timezone *Timezone) error
	TimezoneList(options TimezoneQueryOptions) ([]Timezone, error)
}

type Timezone

type Timezone struct {
	dataobject.DataObject
}

func NewTimezone

func NewTimezone() *Timezone

func NewTimezoneFromExistingData

func NewTimezoneFromExistingData(data map[string]string) *Timezone

func (*Timezone) CountryCode

func (o *Timezone) CountryCode() string

func (*Timezone) CreatedAt

func (o *Timezone) CreatedAt() string

func (*Timezone) CreatedAtCarbon

func (o *Timezone) CreatedAtCarbon() carbon.Carbon

func (*Timezone) DeletedAt

func (o *Timezone) DeletedAt() string

func (*Timezone) GlobalName

func (o *Timezone) GlobalName() string

func (*Timezone) Offset

func (o *Timezone) Offset() string

func (*Timezone) SetCountryCode

func (o *Timezone) SetCountryCode(countryCode string) *Timezone

func (*Timezone) SetCreatedAt

func (o *Timezone) SetCreatedAt(createdAt string) *Timezone

func (*Timezone) SetDeletedAt

func (o *Timezone) SetDeletedAt(deletedAt string) *Timezone

func (*Timezone) SetGlobalName

func (o *Timezone) SetGlobalName(globalName string) *Timezone

func (*Timezone) SetOffset

func (o *Timezone) SetOffset(offset string) *Timezone

func (*Timezone) SetStatus

func (o *Timezone) SetStatus(status string) *Timezone

func (*Timezone) SetTimezone

func (o *Timezone) SetTimezone(timezone string) *Timezone

func (*Timezone) SetUpdatedAt

func (o *Timezone) SetUpdatedAt(updatedAt string) *Timezone

func (*Timezone) SetZoneName

func (o *Timezone) SetZoneName(zoneName string) *Timezone

func (*Timezone) Status

func (o *Timezone) Status() string

func (*Timezone) Timezone

func (o *Timezone) Timezone() string

func (*Timezone) UpdatedAt

func (o *Timezone) UpdatedAt() string

func (*Timezone) UpdatedAtCarbon

func (o *Timezone) UpdatedAtCarbon() carbon.Carbon

func (*Timezone) ZoneName

func (o *Timezone) ZoneName() string

type TimezoneQueryOptions

type TimezoneQueryOptions struct {
	ID          string
	Status      string
	StatusIn    []string
	CountryCode string
	Timezone    string
	Offset      int
	Limit       int
	SortOrder   string
	OrderBy     string
	CountOnly   bool
	WithDeleted bool
}

Jump to

Keyboard shortcuts

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