Documentation
¶
Overview ¶
Package schema provides methods to build JSON schema of the collections from user defined models.
Collection model is declared using Go struct tags. The "tigris" tag contains field properties. The following properties are recognised:
- primary_key - declares primary key of the collection
Composite primary keys defined using optional tag indexes.
Special tag value "-" can be specified to skip field persistence. Unexported fields are not persisted too.
Index ¶
- func Build(sch *Schema) (driver.Schema, error)
- func DatabaseModelName(s interface{}) string
- func FromCollectionModels(model Model, models ...Model) (map[string]*Schema, error)
- func FromDatabaseModel(dbModel interface{}) (string, map[string]*Schema, error)
- func ModelName(s interface{}) string
- type Field
- type Model
- type PrimitiveFieldType
- type Schema
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DatabaseModelName ¶
func DatabaseModelName(s interface{}) string
DatabaseModelName returns name of the database derived from the given database model
func FromCollectionModels ¶
FromCollectionModels converts provided model(s) to the schema structure
func FromDatabaseModel ¶
FromDatabaseModel converts provided database model to collections schema structures
Types ¶
type Field ¶
type Field struct { Type string `json:"type,omitempty"` Format string `json:"format,omitempty"` Tags []string `json:"tags,omitempty"` Desc string `json:"description,omitempty"` Fields map[string]*Field `json:"properties,omitempty"` Items *Field `json:"items,omitempty"` AutoGenerate bool `json:"autoGenerate,omitempty"` }
Field represents JSON schema object
type PrimitiveFieldType ¶
type PrimitiveFieldType interface { string | int | int32 | int64 | float32 | float64 | []byte | time.Time | uuid.UUID }
PrimitiveFieldType represents types supported by non-composite fields