filemaker

package module
v2.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FindCommand

type FindCommand map[string]interface{}

FindCommand represents the findcommand

func NewFindCommand

func NewFindCommand(requests ...interface{}) FindCommand

NewFindCommand returns a findrequest

func (*FindCommand) AddRequest

func (c *FindCommand) AddRequest(request FindRequest)

AddRequest appends a specified FindRequest to the FindCommand

func (FindCommand) SetLimit

func (c FindCommand) SetLimit(limit int) FindCommand

SetLimit sets the limit for the number of records returned by the findcommand

func (FindCommand) SetOffset

func (c FindCommand) SetOffset(offset int) FindCommand

SetOffset sets the offset for the records returned by the findcommand

type FindCriterion

type FindCriterion struct {
	FieldName string
	Value     interface{}
}

FindCriterion represents the findcriterion that builds up a findrequest

func NewFindCriterion

func NewFindCriterion(fieldName string, value interface{}) FindCriterion

NewFindCriterion returns a new findcriterion

type FindRequest

type FindRequest map[string]interface{}

FindRequest represents the findrequest that builds up a findcommand

func NewFindRequest

func NewFindRequest(criterions ...FindCriterion) FindRequest

NewFindRequest returns a new findrequest

func (*FindRequest) AddCriterion

func (r *FindRequest) AddCriterion(criterion FindCriterion)

AddCriterion appends a specified FindCriterion to the FindRequest

func (FindRequest) Omit

func (r FindRequest) Omit() FindRequest

Omit sets the findrequest to omit matching records

type Record

type Record struct {
	ID            string
	Layout        string
	StagedChanges map[string]interface{}
	FieldData     map[string]interface{}
	Session       *Session
}

Record interface for some magic with methods

func (*Record) Bool added in v2.1.0

func (r *Record) Bool(fieldName string) (bool, error)

Bool gets the data in the specified field and returns it as an bool. The FileMaker database field needs to be a number field. Numbers larger than `0` return `true` and `0` or below returns `false`.

func (*Record) Commit

func (r *Record) Commit() error

Commit commits the changes made to the record using the same session the record was retrieved/created with

func (*Record) CommitFileToContainer added in v2.4.0

func (r *Record) CommitFileToContainer(fieldName, filepath string) error

CommitFileToContainer commits the specified file to specified container field in the record

func (*Record) CommitToContainer added in v2.3.0

func (r *Record) CommitToContainer(fieldName string, filename string, dataBuf bytes.Buffer) error

CommitToContainer commits the specified bytes buffer to the specified container field in the record.

func (*Record) Create

func (r *Record) Create() error

Create inserts the record into the database if it doesn't exist

func (*Record) Delete

func (r *Record) Delete() error

Delete deletes the record using the same session the record was retrieved with

func (*Record) Float32 added in v2.1.0

func (r *Record) Float32(fieldName string) (float32, error)

Float32 gets the data in the specified field and returns it as an float32. The FileMaker database field needs to be a number field.

func (*Record) Float64 added in v2.1.0

func (r *Record) Float64(fieldName string) (float64, error)

Float64 gets the data in the specified field and returns it as an float64. The FileMaker database field needs to be a number field.

func (*Record) GetField

func (r *Record) GetField(fieldName string) interface{}

GetField gets the value of a field in the given record and returns it as an `interface{}`

func (*Record) Int added in v2.1.0

func (r *Record) Int(fieldName string) (int, error)

Int gets the data in the specified field and returns it as an int. The FileMaker database field needs to be a number field.

func (*Record) Int32 added in v2.1.0

func (r *Record) Int32(fieldName string) (int32, error)

Int32 gets the data in the specified field and returns it as an int32. The FileMaker database field needs to be a number field.

func (*Record) Int64 added in v2.1.0

func (r *Record) Int64(fieldName string) (int64, error)

Int64 gets the data in the specified field and returns it as an int64. The FileMaker database field needs to be a number field.

func (*Record) Map added in v2.2.0

func (r *Record) Map(obj interface{}) error

Map takes a struct and inserts the field data of the record in the struct fields with an `fm`-tag matching the record field name.

Example struct: `

type example struct {
	Name string `fm:"Name"`
	Age int `fm:"Age"`
}

`

- A pointer to the object must be passed (i.e `Record.Map(&obj)`).

- Nested structs are not supported.

Supported types:

- string

- int

- int64

- float64

- bool

func (*Record) Revert

func (r *Record) Revert()

Revert discards all uncommited changes made to the record

func (*Record) SetField

func (r *Record) SetField(fieldName string, value interface{})

SetField sets the value of a specified field in the given record

func (*Record) String added in v2.1.0

func (r *Record) String(fieldName string) (string, error)

String gets the data in the specified field and returns it as a string. The FileMaker database field needs to be a text field.

type ResponseBody

type ResponseBody struct {
	Messages []struct {
		Code    string `json:"code"`
		Message string `json:"message"`
	} `json:"messages"`
	Response struct {
		Token    string `json:"token"`
		ModID    string `json:"modId"`
		RecordID string `json:"recordId"`
		DataInfo struct {
			Database         string `json:"database"`
			Layout           string `json:"layout"`
			Table            string `json:"table"`
			TotalRecordCount int    `json:"totalRecordCount"`
			FoundCount       int    `json:"foundCount"`
			ReturnedCount    int    `json:"returnedCount"`
		} `json:"dataInfo"`
		Data []interface{} `json:"data"`
	} `json:"response"`
}

ResponseBody represents the json body received from http requests to the filemaker api

type Session

type Session struct {
	Token    string
	Protocol string
	Host     string
	Database string
	Username string
	Password string
}

Session is used for subsequent requests to the host

func New

func New(host string, database string, username string, password string) (*Session, error)

New starts a database session

func Resume

func Resume(host string, database string, username string, password string, token string) (*Session, error)

Resume resumes a database session with the specified token

func (*Session) CreateRecord

func (s *Session) CreateRecord(layout string) Record

CreateRecord returns a new empty record for the specified layout

func (*Session) Destroy

func (s *Session) Destroy() error

Destroy logs out of the database session

func (*Session) PerformFind

func (s *Session) PerformFind(layout string, findCommand interface{}) ([]Record, error)

PerformFind performs the specified findcommand on the specified layout

Jump to

Keyboard shortcuts

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