Documentation ¶
Overview ¶
Package load is the interface for loading an mongox/schema package into a Go program.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { // Path is the path for the schema package. Path string // Names are the schema names to load. Empty means all schemas in the directory. Names []string // BuildFlags are forwarded to the package.Config when // loading the schema package. BuildFlags []string }
Config holds the configuration for loading an mongox/schema package.
func (*Config) Load ¶
func (c *Config) Load() (*SchemaSpec, error)
Load loads the schemas package and build the Go plugin with this info.
type Field ¶
type Field struct { Tag string `json:"tag,omitempty"` Name string `json:"name,omitempty"` FieldType types.MongoType `json:"type,omitempty"` Optional bool `json:"optional,omitempty"` EmbedData []*Field `json:"embed_data,omitempty"` ArrayType types.MongoType `json:"array_type,omitempty"` }
Field represents an ent.Field that was loaded from a complied user package.
type Index ¶
type Index struct { StorageKey string `json:"storage_key,omitempty"` Unique bool `json:"unique,omitempty"` Background bool `json:"background,omitempty"` Sparse bool `json:"sparse,omitempty"` Expire time.Duration `json:"expire,omitempty"` Keys []types.MapEntry `json:"keys,omitempty"` }
Index represents an ent.Index that was loaded from a complied user package.
func NewIndex ¶
func NewIndex(idx *index.Descriptor) *Index
NewIndex creates an loaded index from index descriptor.
type Schema ¶
type Schema struct { Name string `json:"name,omitempty"` Fields []*Field `json:"fields,omitempty"` Indexes []*Index `json:"indexes,omitempty"` }
Schema represents an ent.Schema that was loaded from a complied user package.
func UnmarshalSchema ¶
UnmarshalSchema decodes the given buffer to a loaded schema.
type SchemaSpec ¶
type SchemaSpec struct { // Schemas defines the loaded schema descriptors. Schemas []*Schema // PkgPath is the package path of the loaded // mongox.Schema package. PkgPath string // Module defines the module information for // the user schema package if exists. Module *packages.Module }
A SchemaSpec holds a serializable version of an mongox.Schema and its Go package and module information.