Versions in this module Expand all Collapse all v0 v0.0.7 Apr 22, 2024 v0.0.6 Apr 22, 2024 v0.0.5 Apr 15, 2024 Changes in this version + func IsNotFound(err error) bool type App + Disks func() []Disk + OnPostDBGet func(PostDBGetHook) + OnPostResolve func(hooks ...Middleware) + OnPreResolve func(hooks ...Middleware) + type CountOption struct + Column string + Unique bool + type DBClient interface + Close func() error + Commit func() error + Config func() *DBConfig + CreateDBModel func(s *schema.Schema, rs ...*schema.Relation) Model + DB func() *sql.DB + Dialect func() string + Exec func(ctx context.Context, query string, args any, bindValue any) error + Hooks func() *Hooks + IsTx func() bool + Model func(name string) (Model, error) + Reload func(newSchemaBuilder *schema.Builder, migration *Migration) (DBClient, error) + Rollback func() error + SchemaBuilder func() *schema.Builder + Tx func(ctx context.Context) (DBClient, error) + type DBConfig struct + Driver string + Hooks func() *Hooks + Host string + IgnoreMigration bool + LogQueries bool + Logger Logger + MigrationDir string + Name string + Pass string + Port string + User string + func (c *DBConfig) Clone() *DBConfig type Disk + LocalPublicPath func() string + Root func() string type DiskConfig + PublicPath string type Hooks + PostDBGet []PostDBGetHook + PostResolve []ResolveHook + PreResolve []ResolveHook + type LogContext Map + type Logger interface + DPanic func(...any) + Debug func(...any) + Error func(...any) + Errorf func(string, ...any) + Fatal func(...any) + Info func(...any) + Infof func(string, ...any) + Panic func(...any) + Warn func(...any) + WithContext func(context LogContext, callerSkips ...int) Logger + type Migration struct + Dir string + RenameFields []*RenameItem + RenameTables []*RenameItem + type MockLogger struct + Messages []*MockLoggerMessage + Silence bool + func CreateMockLogger(silences ...bool) *MockLogger + func (l *MockLogger) DPanic(params ...any) + func (l *MockLogger) Debug(params ...any) + func (l *MockLogger) Error(params ...any) + func (l *MockLogger) Errorf(msg string, params ...any) + func (l *MockLogger) Fatal(params ...any) + func (l *MockLogger) Info(params ...any) + func (l *MockLogger) Infof(msg string, params ...any) + func (l *MockLogger) Last() MockLoggerMessage + func (l *MockLogger) Panic(params ...any) + func (l *MockLogger) Warn(params ...any) + func (l *MockLogger) WithContext(context LogContext, callerSkips ...int) Logger + type MockLoggerMessage struct + Params []any + Type string + func (m MockLoggerMessage) String() string + type Model interface + Clone func() Model + Create func(e *schema.Entity) (id uint64, err error) + CreateFromJSON func(json string) (id uint64, err error) + Mutation func(skipTxs ...bool) Mutation + Query func(predicates ...*Predicate) Query + Schema func() *schema.Schema + SetClient func(client DBClient) Model + type Mutation interface + Create func(e *schema.Entity) (id uint64, err error) + Delete func() (affected int, err error) + GetRelationEntityIDs func(fieldName string, fieldValue any) ([]driver.Value, error) + Update func(e *schema.Entity) (affected int, err error) + Where func(predicates ...*Predicate) Mutation + type NotFoundError struct + Message string + func (e *NotFoundError) Error() string + type OperatorType int + const OpEQ + const OpGT + const OpGTE + const OpIN + const OpInvalid + const OpLIKE + const OpLT + const OpLTE + const OpNEQ + const OpNIN + const OpNULL + func (t *OperatorType) UnmarshalJSON(b []byte) error + func (t OperatorType) MarshalJSON() ([]byte, error) + func (t OperatorType) String() string + func (t OperatorType) Valid() bool + type PaginationInfo struct + CurrentPage uint + LastPage uint + PerPage uint + Total uint + type PostDBGetHook = func(query *QueryOption, entities []*schema.Entity) ([]*schema.Entity, error) + type Predicate struct + And []*Predicate + Field string + Operator OperatorType + Or []*Predicate + RelationFieldNames []string + Value any + func And(predicates ...*Predicate) *Predicate + func CreatePredicatesFromFilterObject(sb *schema.Builder, s *schema.Schema, filterObject string) ([]*Predicate, error) + func EQ(field string, value any, relationFields ...string) *Predicate + func GT(field string, value any, relationFields ...string) *Predicate + func GTE(field string, value any, relationFields ...string) *Predicate + func In(field string, values []any, relationFields ...string) *Predicate + func IsFalse(field string, relationFields ...string) *Predicate + func IsTrue(field string, relationFields ...string) *Predicate + func LT(field string, value any, relationFields ...string) *Predicate + func LTE(field string, value any, relationFields ...string) *Predicate + func Like(field string, value string, relationFields ...string) *Predicate + func NEQ(field string, value any, relationFields ...string) *Predicate + func NotIn(field string, values []any, relationFields ...string) *Predicate + func Null(field string, value bool, relationFields ...string) *Predicate + func Or(predicates ...*Predicate) *Predicate + func (p *Predicate) Clone() *Predicate + type Query interface + Count func(options *CountOption, ctxs ...context.Context) (int, error) + First func(ctxs ...context.Context) (*schema.Entity, error) + Get func(ctxs ...context.Context) ([]*schema.Entity, error) + Limit func(limit uint) Query + Offset func(offset uint) Query + Only func(ctxs ...context.Context) (*schema.Entity, error) + Options func() *QueryOption + Order func(order ...string) Query + Select func(columns ...string) Query + Where func(predicates ...*Predicate) Query + type QueryOption struct + Columns []string + Limit uint + Model Model + Offset uint + Order []string + Predicates []*Predicate + type RenameItem struct + From string + IsJunctionTable bool + SchemaName string + SchemaNamespace string + To string + Type string type ResourcesManager + Hooks func() *Hooks type Role + func EntitiesToRoles(entities []*schema.Entity) []*Role + type StaticFs struct + BasePath string + PathPrefix string + Root http.FileSystem v0.0.4 Apr 5, 2024 v0.0.3 Apr 5, 2024 Changes in this version type DiskConfig + func (dc *DiskConfig) Clone() *DiskConfig type StorageConfig + func (sc *StorageConfig) Clone() *StorageConfig v0.0.2 Apr 4, 2024 v0.0.1 Apr 3, 2024 Changes in this version + const DELETE + const GET + const OPTIONS + const PATCH + const POST + const PUT + var AllowedFileTypes = []string + var GuestUser = &User + var PermissionTypeToStrings = [...]string + var RoleAdmin = &Role + var RoleGuest = &Role + var RoleUser = &Role + func PermissionTypeValues() []string + type App interface + AddMiddlewares func(hooks ...Middleware) + AddResource func(resource *Resource) + DB func() db.Client + Disk func(names ...string) Disk + GetRoleDetail func(roleID uint64) *Role + GetRolePermission func(roleID uint64, action string) *Permission + GetRolesFromIDs func(ids []uint64) []*Role + Hooks func() *Hooks + Key func() string + Logger func() logger.Logger + OnAfterDBContentList func(db.AfterDBContentListHook) + OnAfterResolve func(hooks ...Middleware) + OnBeforeResolve func(hooks ...Middleware) + Reload func(migration *db.Migration) (err error) + Resources func() *ResourcesManager + Roles func() []*Role + SchemaBuilder func() *schema.Builder + UpdateCache func() error + type Context interface + Arg func(string, ...string) string + ArgInt func(string, ...int) int + Args func() map[string]string + AuthToken func() string + Context func() context.Context + Entity func() (*schema.Entity, error) + Files func() ([]*File, error) + ID func() string + Logger func() logger.Logger + Next func() error + Parse func(any) error + Resource func() *Resource + Result func(...*Result) *Result + User func() *User + Value func(string, ...any) (val any) + type Disk interface + Delete func(c context.Context, filepath string) error + Name func() string + Put func(c context.Context, file *File) (*File, error) + PutMultipart func(c context.Context, m *multipart.FileHeader, dsts ...string) (*File, error) + PutReader func(c context.Context, in io.Reader, size uint64, mime, dst string) (*File, error) + URL func(filepath string) string + type DiskConfig struct + ACL string + AccessKeyID string + BaseURL string + Bucket string + Driver string + Endpoint string + GetBaseURL func() string + Name string + Provider string + Region string + Root string + SecretAccessKey string + type File struct + CreatedAt *time.Time + DeletedAt *time.Time + Disk string + ID uint64 + Name string + Path string + Reader io.Reader + Size uint64 + Type string + URL string + UpdatedAt *time.Time + User *User + UserID uint64 + func EntitiesToFiles(entities []*schema.Entity, disks ...Disk) []*File + func EntityToFile(e *schema.Entity, disks ...Disk) *File + type Hooks struct + AfterResolve []ResolveHook + BeforeResolve []ResolveHook + ContentList []db.AfterDBContentListHook + type Map map[string]any + type Meta map[string]any + type Middleware func(c Context) error + type Pagination struct + Data any + Pagination *PaginationData + func NewPagination(total, perPage, currentPage uint, data any) *Pagination + type PaginationData struct + CurrentPage uint + LastPage uint + PerPage uint + Total uint + type Permission struct + CreatedAt *time.Time + DeletedAt *time.Time + ID int + Resource string + Role *Role + RoleID int + UpdatedAt *time.Time + Value string + type PermissionType uint + const PermissionTypeAllow + const PermissionTypeDeny + const PermissionTypeInvalid + func GetPermissionTypeFromName(name string) PermissionType + func (p *PermissionType) UnmarshalJSON(b []byte) error + func (p PermissionType) MarshalJSON() ([]byte, error) + func (p PermissionType) String() string + func (p PermissionType) Valid() bool + type ResolveHook = Middleware + type Resolver func(c Context) (any, error) + type ResolverGenerator func(c Context, input *Input) (Output, error) + type Resource struct + func NewResource[Input, Output any](name string, resolverGenerator ResolverGenerator[Input, Output], extras ...any) *Resource + func (r *Resource) Add(resource *Resource) (self *Resource) + func (r *Resource) AddResource(name string, resolver Resolver, extras ...any) (self *Resource) + func (r *Resource) Clone() *Resource + func (r *Resource) Find(resourceID string) *Resource + func (r *Resource) Group(name string, resources ...*Resource) (group *Resource) + func (r *Resource) ID() string + func (r *Resource) Init() error + func (r *Resource) IsGroup() bool + func (r *Resource) MarshalJSON() ([]byte, error) + func (r *Resource) Meta() Meta + func (r *Resource) Name() string + func (r *Resource) Print() + func (r *Resource) Remove(resource *Resource) (self *Resource) + func (r *Resource) Resolver() Resolver + func (r *Resource) Resources() []*Resource + func (r *Resource) String() string + func (r *Resource) WhiteListed() bool + type ResourcesManager struct + AfterResolveHooks []Middleware + BeforeResolveHooks []Middleware + Middlewares []Middleware + StaticResources []*StaticResourceConfig + func NewResourcesManager() *ResourcesManager + func (rs *ResourcesManager) Init() error + func (rs *ResourcesManager) RegisterStaticResources(configs ...*StaticResourceConfig) + type Result struct + Data any + Error *errors.Error + func NewResult(data any, err error) *Result + type Role struct + CreatedAt *time.Time + DeletedAt *time.Time + Description string + ID uint64 + Name string + Permissions []*Permission + Root bool + UpdatedAt *time.Time + Users []*User + func EntityToRole(e *schema.Entity) *Role + type Signature = [2]any + type StaticResourceConfig struct + BasePath string + PathPrefix string + Root http.FileSystem + type StorageConfig struct + DefaultDisk string + DisksConfig []*DiskConfig + type User struct + Active bool + CreatedAt *time.Time + DeletedAt *time.Time + Email string + Entity *schema.Entity + ID uint64 + Password string + Provider string + ProviderID string + ProviderUsername string + RoleIDs []uint64 + Roles []*Role + UpdatedAt *time.Time + Username string + func EntityToUser(e *schema.Entity) *User + func (u *User) IsRoot() bool + func (u *User) JwtClaim(exp time.Time, key string, jwtHeaders ...map[string]any) (string, error) + type UserJwtClaims struct + User *User