Documentation
¶
Overview ¶
Package sheetdb is a package for using Google spreadsheets as a database instead of the actual database management system. This package is used with the code generated by the `sheetdb-modeler` tool. For details, please refer to usage of README.md.
Index ¶
- func ModelSetName(modelSetName string) func(client *Client) *Client
- func RegisterModel(modelSetName, modelName, sheetName string, ...)
- func SetLogLevel(l LogLevel)
- func SetLogger(l Logger)
- type Client
- type ClientOption
- type Date
- type Datetime
- type DuplicationError
- type EmptyStringError
- type InvalidFormatError
- type InvalidValueError
- type LogLevel
- type Logger
- type NotFoundError
- type SlackLogger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ModelSetName ¶
ModelSetName is an option to change model set name using by client. If not used, the "default" model set is used.
func RegisterModel ¶
func RegisterModel(modelSetName, modelName, sheetName string, loadFunc func(data *gsheets.Sheet) error)
RegisterModel registers the model specified as an argument into a model set. This function is usually called from generated code.
func SetLogLevel ¶
func SetLogLevel(l LogLevel)
SetLogLevel sets a log level for this package. If you don't use the default logger or SlackLogger, log level are meaningless. The default log level is "INFO".
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a client of this package. Create a new client with the `New` function.
func (*Client) AsyncUpdate ¶
func (c *Client) AsyncUpdate(data []gsheets.UpdateValue) error
AsyncUpdate applies updates to s spreadsheet asynchronously. This function is usually called from generated code. Even though it's called Async this function is a synchronous blocking call. Because the original implementation DISCARDS ERRORS, and I can't be having that
in a database implementation. If I retain sheetsdb and perf becomes an issue i'll look to plumb channels through here to communicate errors.
type ClientOption ¶
ClientOption is an option to change the behavior of the client.
type Date ¶
Date is date (YYYY-MM-DD).
func (*Date) MarshalJSON ¶
MarshalJSON marshals date value.
type Datetime ¶
Datetime is datetime (YYYY-MM-DDTHH:mm:ssZ0700).
func NewDatetime ¶
NewDatetime returns new Datetime.
func (*Datetime) MarshalJSON ¶
MarshalJSON marshals datetime value.
type DuplicationError ¶
type DuplicationError struct {
FieldName string
}
DuplicationError means that field value that should be unique is duplicated.
func (*DuplicationError) Error ¶
func (e *DuplicationError) Error() string
type EmptyStringError ¶
type EmptyStringError struct {
FieldName string
}
EmptyStringError means that string field that does not allow empty is empty.
func (*EmptyStringError) Error ¶
func (e *EmptyStringError) Error() string
type InvalidFormatError ¶
type InvalidFormatError struct {
Err error
}
InvalidFormatError means that the format is invalid.
func (*InvalidFormatError) Error ¶
func (e *InvalidFormatError) Error() string
type InvalidValueError ¶
InvalidValueError means that field value is invalid.
func (*InvalidValueError) Error ¶
func (e *InvalidValueError) Error() string
type LogLevel ¶
type LogLevel int
LogLevel represents the level of logging when using the default logger.
type Logger ¶
type Logger interface { Debugf(format string, v ...interface{}) Infof(format string, v ...interface{}) Errorf(format string, v ...interface{}) }
Logger is an interface for logging of this package.
type NotFoundError ¶
type NotFoundError struct {
Model string
}
NotFoundError means that model is not found.
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
type SlackLogger ¶
type SlackLogger struct {
// contains filtered or unexported fields
}
SlackLogger is a logget to output log to slack. Logs are also output to standard output and standard error output at the same time, and you can control each log level.
func NewSlackLogger ¶
func NewSlackLogger(projectName, serviceName, iconEmoji, errorURL string, slackLogLevel LogLevel) *SlackLogger
NewSlackLogger returns a new SlackLogger.
func (*SlackLogger) Debugf ¶
func (l *SlackLogger) Debugf(format string, v ...interface{})
Debugf outputs a log whose log level is Debug or higher.
func (*SlackLogger) Errorf ¶
func (l *SlackLogger) Errorf(format string, v ...interface{})
Errorf outputs a log whose log level is Error or higher.
func (*SlackLogger) Infof ¶
func (l *SlackLogger) Infof(format string, v ...interface{})
Infof outputs a log whose log level is Info or higher.