Documentation ¶
Index ¶
- Constants
- Variables
- func ContributeBarcode(stmt *sql.Stmt, rec BARCODE, acc *ACCOUNT) (string, error)
- func ContributeBarcodeBrand(stmt *sql.Stmt, rec BARCODE, brand *BRAND) error
- func ContributeBrand(stmt *sql.Stmt, rec *CONTRIBUTED_BRAND, acc *ACCOUNT) error
- func GenerateUUID(fn func([]byte) string) string
- func InsertAsin(stmt *sql.Stmt, rec AMAZON) error
- type ACCOUNT
- type AMAZON
- type BARCODE
- type BRAND
- type CONTRIBUTED_BRAND
- type GTIN
Constants ¶
View Source
const ( // Create/Update/Delete ACCOUNT_INSERT = "insert into account (id, email, verify_code) values (unhex(?), ?, ?)" ACCOUNT_UPDATE = "update account set email = ?, verified = ?, enabled = ?, date_verified=NOW() where id = unhex(?)" ACCOUNT_DELETE = "delete from account where id = unhex(?)" // Lookup ACCOUNT_LOOKUP_BY_EMAIL = "select hex(id), verify_code, verified, enabled from account where email = ?" ACCOUNT_LOOKUP_BY_ID = "select email, verify_code, verified, enabled from account where id = unhex(?)" )
View Source
const ( // Amazon ASIN_LOOKUP = "select asin, product, is_upc, is_ean, is_isbn, locale from amazon where barcode = ?" ASIN_INSERT = "insert into amazon (id, barcode, asin, product, is_upc, is_ean, is_isbn, locale) values (unhex(?), ?, ?, ?, ?, ?, ?, ?)" )
View Source
const ( // Barcode Types UPC = "UPC" EAN = "EAN" ISBN = "ISBN" )
View Source
const ( // Prepared Queries (POD) GTIN_LOOKUP = "select gtin_nm, bsin from gtin where gtin_cd = ?" BRAND_LOOKUP = "select brand_nm, brand_link from brand where bsin = ?" BRAND_NAME_LOOKUP = "select bsin, brand_nm, brand_link from brand where brand_nm like ?" // User contributions BARCODE_LOOKUP = "select hex(id), product_name, product_desc, is_edit, hex(account_id) from barcode where barcode = ?" BARCODE_INSERT = "insert into barcode (id, barcode, product_name, product_desc, is_edit, account_id) values (unhex(?), ?, ?, ?, ?, unhex(?))" BARCODE_BRAND_INSERT = "insert into barcode_brand (id, bsin, barcode_id) values (unhex(?), ?, unhex(?))" CONTRIBUTED_BRAND_LOOKUP = "select hex(id), brand_name, brand_url, hex(account_id) from contributed_brand where brand_name like ?" CONTRIBUTED_BRAND_INSERT = "insert into contributed_brand (id, brand_name, brand_url, account_id) values (unhex(?), ?, ?, unhex(?))" )
Variables ¶
View Source
var ( // Formatting function: take the 16 random bytes and return them as a string // of 8-4-4-4-12 tuples, separated by dashes DashedUUID = func(b []byte) string { return fmt.Sprintf("%x-%x-%x-%x-%x", b[0:4], b[4:6], b[6:8], b[8:10], b[10:]) } // An alternative formatting function: take the 16 random bytes and return // them as a single string, with no dashes UndashedUUID = func(b []byte) string { return fmt.Sprintf("%x", b) } )
Functions ¶
func ContributeBarcode ¶
func ContributeBarcodeBrand ¶
func ContributeBrand ¶
func ContributeBrand(stmt *sql.Stmt, rec *CONTRIBUTED_BRAND, acc *ACCOUNT) error
func GenerateUUID ¶
Generate a universally unique identifier (UUID) using the computer's /dev/urandom output as a randomizer, returning a string specified by the given formatting function
Types ¶
type ACCOUNT ¶
type ACCOUNT struct { Id string `json:"pk"` Email string `json:"email"` APICode string `json:"code"` Verified bool `json:"verified,omitempty"` Enabled bool `json:"enabled,omitempty"` }
func LookupAccount ¶
LookupAccount searches for the Account using either the id (uuid) or email address string parameter, depending on which prepared statement and boolean flag is passed
type AMAZON ¶
type BARCODE ¶
type BRAND ¶
type BRAND struct { Id string `json:"bsin"` Name string `json:"brand,omitempty"` URL string `json:"url,omitempty"` }
func LookupBrand ¶
LookupBrand takes a prepared statment (using the BRAND_LOOKUP string), a bsin (brand id) string, and looks it up in POD, returning a list of matching BRAND structs
type CONTRIBUTED_BRAND ¶
type CONTRIBUTED_BRAND struct { Uuid string `json:"id"` Name string `json:"brand,omitempty"` URL string `json:"url,omitempty"` AccountID string `json:"account"` }
func LookupContributedBrand ¶
func LookupContributedBrand(stmt *sql.Stmt, brandName string) ([]*CONTRIBUTED_BRAND, error)
Click to show internal directories.
Click to hide internal directories.