Documentation ¶
Index ¶
- Variables
- type Client
- func (c *Client) ThingDeleteByID(ctx context.Context, id string) error
- func (c *Client) ThingGetByID(ctx context.Context, id string) (*gorestapi.Thing, error)
- func (c *Client) ThingSave(ctx context.Context, record *gorestapi.Thing) error
- func (c *Client) ThingsFind(ctx context.Context, qp *queryp.QueryParameters) ([]*gorestapi.Thing, *int64, error)
- func (c *Client) WidgetDeleteByID(ctx context.Context, id string) error
- func (c *Client) WidgetGetByID(ctx context.Context, id string) (*gorestapi.Widget, error)
- func (c *Client) WidgetSave(ctx context.Context, record *gorestapi.Widget) error
- func (c *Client) WidgetsFind(ctx context.Context, qp *queryp.QueryParameters) ([]*gorestapi.Widget, *int64, error)
- type Config
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ThingTable = postgres.Generate(postgres.Table[gorestapi.Thing]{ Table: `"thing"`, Fields: []*postgres.Field[gorestapi.Thing]{ {Name: "id", ID: true, Insert: "$#", Value: func(rec *gorestapi.Thing) (driver.Value, error) { return rec.ID, nil }}, {Name: "created", Insert: "NOW()", NullVal: "0001-01-01 00:00:00 UTC"}, {Name: "updated", Insert: "NOW()", Update: "NOW()", NullVal: "0001-01-01 00:00:00 UTC"}, {Name: "name", Insert: "$#", Update: "$#", Value: func(rec *gorestapi.Thing) (driver.Value, error) { return rec.Name, nil }}, {Name: "description", Insert: "$#", Update: "$#", Value: func(rec *gorestapi.Thing) (driver.Value, error) { return rec.Description, nil }}, }, Selector: postgres.Selector[gorestapi.Thing]{ FilterFieldTypes: queryp.FilterFieldTypes{ "thing.id": queryp.FilterTypeSimple, "thing.created": queryp.FilterTypeTime, "thing.updated": queryp.FilterTypeTime, "thing.name": queryp.FilterTypeString, "thing.description": queryp.FilterTypeString, }, SortFields: queryp.SortFields{ "thing.id": "", "thing.created": "", "thing.updated": "", "thing.name": "", "thing.description": "", }, DefaultSort: queryp.Sort{ &queryp.SortTerm{Field: "thing.name", Desc: false}, }, }, }) )
View Source
var ( WidgetTable = postgres.Generate(postgres.Table[gorestapi.Widget]{ Table: `"widget"`, Fields: []*postgres.Field[gorestapi.Widget]{ {Name: "id", ID: true, Insert: "$#", Value: func(rec *gorestapi.Widget) (driver.Value, error) { return rec.ID, nil }}, {Name: "created", Insert: "NOW()", NullVal: "0001-01-01 00:00:00 UTC"}, {Name: "updated", Insert: "NOW()", Update: "NOW()", NullVal: "0001-01-01 00:00:00 UTC"}, {Name: "name", Insert: "$#", Update: "$#", Value: func(rec *gorestapi.Widget) (driver.Value, error) { return rec.Name, nil }}, {Name: "description", Insert: "$#", Update: "$#", Value: func(rec *gorestapi.Widget) (driver.Value, error) { return rec.Description, nil }}, {Name: "thing_id", Insert: "$#", Update: "$#", Value: func(rec *gorestapi.Widget) (driver.Value, error) { return rec.ThingID, nil }}, }, Joins: ` LEFT JOIN thing ON widget.thing_id = thing.id `, Selector: postgres.Selector[gorestapi.Widget]{ FilterFieldTypes: queryp.FilterFieldTypes{ "widget.id": queryp.FilterTypeSimple, "widget.created": queryp.FilterTypeTime, "widget.updated": queryp.FilterTypeTime, "widget.name": queryp.FilterTypeString, "widget.description": queryp.FilterTypeString, "thing.name": queryp.FilterTypeString, "thing.description": queryp.FilterTypeString, }, SortFields: queryp.SortFields{ "widget.id": "", "widget.created": "", "widget.updated": "", "widget.name": "", "widget.description": "", "thing.name": "", "thing.description": "", }, DefaultSort: queryp.Sort{ &queryp.SortTerm{Field: "thing.name", Desc: false}, }, PostProcessRecord: func(rec *gorestapi.Widget) error { if rec.ThingID == nil || *rec.ThingID == "" { rec.Thing = nil } return nil }, }, PostProcessRecord: func(rec *gorestapi.Widget) error { if rec.ThingID == nil || *rec.ThingID == "" { rec.Thing = nil } return nil }, SelectAdditionalFields: ThingTable.GenerateAdditionalFields(true), }) )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) ThingDeleteByID ¶
ThingDeleteByID deletes a record by id
func (*Client) ThingGetByID ¶
ThingGetByID returns the the record by id
func (*Client) ThingsFind ¶
func (c *Client) ThingsFind(ctx context.Context, qp *queryp.QueryParameters) ([]*gorestapi.Thing, *int64, error)
ThingsFind fetches records with filter and pagination
func (*Client) WidgetDeleteByID ¶
WidgetDeleteByID deletes a record by id
func (*Client) WidgetGetByID ¶
WidgetGetByID returns the the record by id
func (*Client) WidgetSave ¶
WidgetSave saves the record
Click to show internal directories.
Click to hide internal directories.