Documentation ¶
Index ¶
- Constants
- Variables
- type DataSource
- type FMAction
- type FMConnector
- type FMError
- type FMFieldOp
- type FMLogicalOp
- type FMQuery
- func (q *FMQuery) Max(n int) *FMQuery
- func (q *FMQuery) QueryString() string
- func (q *FMQuery) Skip(n int) *FMQuery
- func (q *FMQuery) WithFieldGroups(fieldGroups ...FMQueryFieldGroup) *FMQuery
- func (q *FMQuery) WithFields(fields ...FMQueryField) *FMQuery
- func (q *FMQuery) WithPostFindScript(script, param string) *FMQuery
- func (q *FMQuery) WithPreFindScript(script, param string) *FMQuery
- func (q *FMQuery) WithPreSortScript(script, param string) *FMQuery
- func (q *FMQuery) WithRecordID(id int) *FMQuery
- func (q *FMQuery) WithResponseFields(fields ...string) *FMQuery
- func (q *FMQuery) WithResponseLayout(lay string) *FMQuery
- func (q *FMQuery) WithSortFields(sortFields ...FMSortField) *FMQuery
- type FMQueryField
- type FMQueryFieldGroup
- type FMResultset
- type FMSortField
- type FMSortOrder
- type Field
- type FieldDefinition
- type FieldType
- type FieldsDefinitions
- type MetaData
- type Record
- type RelatedSet
- type RelatedSetDefinition
- type Resultset
Constants ¶
const ( // DateFormat is a format of date on a particular layout DateFormat = "01/02/2006" // TimeFormat is a format of time on a particular layout TimeFormat = "15:04:05" // TimestampFormat is a format of timestamp on a particular layout TimestampFormat = "01/02/2006 15:04:05" )
const (
// FMDBNames adds –dbnames (Database names) query command
FMDBNames = "-dbnames"
)
Variables ¶
var FileMakerErrorCodes = map[int]string{}/* 243 elements not displayed */
FileMakerErrorCodes are all error codes taken from FileMaker official documentation
Functions ¶
This section is empty.
Types ¶
type DataSource ¶
type DataSource struct { Database string `xml:"database,attr"` DateFormat string `xml:"date_format,attr"` Layout string `xml:"layout,attr"` Table string `xml:"table,attr"` TimeFormat string `xml:"time-format,attr"` TimestampFormat string `xml:"timestamp-format,attr"` TotalCount int `xml:"total-count,attr"` }
DataSource store database name, layout name and time formats
type FMAction ¶
type FMAction string
FMAction is a type iof action can be done to the record
const ( // Find -findquery Find FMAction = "-findquery" // FindAll -findall FindAll FMAction = "-findall" // FindAny findany FindAny FMAction = "-findany" // New -new New FMAction = "-new" // Edit -edit Edit FMAction = "-edit" // Delete -delete Delete FMAction = "-delete" // Duplicate -dup Duplicate FMAction = "-dup" )
type FMConnector ¶
type FMConnector struct { Host string Port string Username string Password string Client *http.Client Debug bool }
FMConnector includes all the information about FM database to be able to connect to that
func NewFMConnector ¶
func NewFMConnector(host string, port string, username string, password string) *FMConnector
NewFMConnector creates new FMConnector object
func (*FMConnector) Ping ¶
func (fmc *FMConnector) Ping(ctx context.Context) error
Ping sends a simple request querying all available databases in order to check connection and credentials
func (*FMConnector) Query ¶
func (fmc *FMConnector) Query(ctx context.Context, q *FMQuery) (FMResultset, error)
Query fetches FMResultset from FileMaker server depending on FMQuery given to it
func (*FMConnector) SetDebug ¶ added in v0.3.4
func (fmc *FMConnector) SetDebug(v bool)
SetDebug sets debug level of logger to Debug. DON'T use it in production. Your record information can leak to the logs
type FMError ¶
type FMError struct {
Code int `xml:"code,attr"`
}
FMError represents a FileMaker error
type FMFieldOp ¶
type FMFieldOp string
FMFieldOp is type of operator for a FMField
const ( // Equal -eq Equal FMFieldOp = "eq" // Contains -cn Contains FMFieldOp = "cn" // BeginsWith -bw BeginsWith FMFieldOp = "bw" // EndsWith -ew EndsWith FMFieldOp = "ew" // GreaterThan -gt GreaterThan FMFieldOp = "gt" // GreaterThanEqual -gte GreaterThanEqual FMFieldOp = "gte" // LessThan -lt LessThan FMFieldOp = "lt" // LessThanEqual -lte LessThanEqual FMFieldOp = "lte" )
type FMLogicalOp ¶
type FMLogicalOp string
FMLogicalOp is a type for logical operators
const ( // And operator And FMLogicalOp = "and" // Or operator Or FMLogicalOp = "or" // Not operator Not FMLogicalOp = "not" )
type FMQuery ¶
type FMQuery struct { Database string Layout string Action FMAction QueryFields []FMQueryFieldGroup SortFields []FMSortField RecordID int // default should be -1 PreSortScript string PreFindScript string PostFindScript string PreSortScriptParam string PreFindScriptParam string PostFindScriptParam string ResponseLayout string ResponseFields []string MaxRecords int // default should be -1 SkipRecords int // default should be 0 Query map[string]string }
FMQuery represent the query you are sending to the server
func NewFMQuery ¶
NewFMQuery creates new FMQuery object
func (*FMQuery) QueryString ¶
QueryString creates query string based on FMQuery
func (*FMQuery) WithFieldGroups ¶
func (q *FMQuery) WithFieldGroups(fieldGroups ...FMQueryFieldGroup) *FMQuery
WithFieldGroups sets groups of fields for find request
func (*FMQuery) WithFields ¶
func (q *FMQuery) WithFields(fields ...FMQueryField) *FMQuery
WithFields sets field for the find request
func (*FMQuery) WithPostFindScript ¶
WithPostFindScript sets PostFindScript script and params
func (*FMQuery) WithPreFindScript ¶
WithPreFindScript sets PreFindScript and params
func (*FMQuery) WithPreSortScript ¶
WithPreSortScript sets PreSortScript and params
func (*FMQuery) WithRecordID ¶ added in v0.3.5
WithRecordID sets RecordID for the query. MUST have if you want to edit/delete record
func (*FMQuery) WithResponseFields ¶
WithResponseFields adds field names that FileMaker server should return
func (*FMQuery) WithResponseLayout ¶
WithResponseLayout sets layout name you want to fetch records from
func (*FMQuery) WithSortFields ¶
func (q *FMQuery) WithSortFields(sortFields ...FMSortField) *FMQuery
WithSortFields sets sort fields' name and order
type FMQueryField ¶
FMQueryField is a field used in FMQuery
type FMQueryFieldGroup ¶
type FMQueryFieldGroup struct { Op FMLogicalOp Fields []FMQueryField }
FMQueryFieldGroup groups of fields used for the find request
type FMResultset ¶
type FMResultset struct { Resultset *Resultset `xml:"resultset"` DataSource *DataSource `xml:"datasource"` MetaData *MetaData `xml:"metadata"` Version string `xml:"version,attr"` FMError FMError `xml:"error"` }
FMResultset is a collection of ResultSets
func (*FMResultset) HasError ¶
func (rs *FMResultset) HasError() bool
HasError checks if FMResultset was fetched with an error
type FMSortField ¶
type FMSortField struct { Name string Order FMSortOrder }
FMSortField is a field that should be sorted during the query
type FMSortOrder ¶
type FMSortOrder string
FMSortOrder is a type of order
const ( // Ascending -ascend Ascending FMSortOrder = "ascend" // Descending -descend Descending FMSortOrder = "descend" // Custom -custom Custom FMSortOrder = "custom" )
func (FMSortOrder) String ¶
func (so FMSortOrder) String() string
type Field ¶
type Field struct { Name string `xml:"name,attr" json:"field"` Data []string `xml:"data" json:"data"` Type FieldType }
Field stands for field in a record
type FieldDefinition ¶ added in v0.3.0
type FieldDefinition struct { Name string `xml:"name,attr"` AutoEnter bool FourDigitYear bool Global bool MaxRepeat int NotEmpty bool NumericOnly bool TimeOfDay bool Type FieldType }
FieldDefinition store information about a field in given layout
func (*FieldDefinition) UnmarshalXML ¶ added in v0.3.0
func (f *FieldDefinition) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
UnmarshalXML serializes xml data of FieldDefinition into the object
type FieldType ¶ added in v0.3.0
type FieldType string
FieldType represents a type of the field
const ( // TypeText is a text type of the field TypeText FieldType = "text" // TypeNumber is a number type of the field TypeNumber FieldType = "number" // TypeDate is a date type of the field TypeDate FieldType = "date" // TypeTime is a time type of the field TypeTime FieldType = "time" // TypeTimestamp is a timestamp type of the field TypeTimestamp FieldType = "timestamp" // TypeContainer is a container type of the field TypeContainer FieldType = "container" )
type FieldsDefinitions ¶ added in v0.3.0
type FieldsDefinitions []FieldDefinition
FieldsDefinitions is type of []FieldDefinition
type MetaData ¶ added in v0.3.0
type MetaData struct { FieldDefinitions []*FieldDefinition `xml:"field-definition"` RelatedSetDefinition *RelatedSetDefinition `xml:"relatedset-definition"` }
MetaData store fields' and related sets' meta information
type Record ¶
type Record struct { ID int `xml:"record-id,attr"` Fields []*Field `xml:"field"` RelatedSet []*RelatedSet `xml:"relatedset"` // contains filtered or unexported fields }
Record is FileMaker record
func (*Record) JSONFields ¶ added in v0.3.5
JSONFields return JSON representation of Record
func (*Record) RelatedSetFromTable ¶
func (r *Record) RelatedSetFromTable(t string) *RelatedSet
RelatedSetFromTable returns the set of related records from given related table
type RelatedSet ¶
type RelatedSet struct { Count int `xml:"count,attr"` Table string `xml:"table,attr"` Records []*Record `xml:"record"` }
RelatedSet is a set of records returned from FileMaker database
type RelatedSetDefinition ¶ added in v0.3.0
type RelatedSetDefinition struct { Table string `xml:"table,attr"` FieldDefinitions []*FieldDefinition `xml:"field-definition"` }
RelatedSetDefinition is meta information of related set