Skip to main content
Glama

Storyden

by Southclaws
Mozilla Public License 2.0
227
category.go11 kB
// Code generated by ent, DO NOT EDIT. package ent import ( "encoding/json" "fmt" "strings" "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" "github.com/Southclaws/storyden/internal/ent/asset" "github.com/Southclaws/storyden/internal/ent/category" "github.com/rs/xid" ) // Category is the model entity for the Category schema. type Category struct { config `json:"-"` // ID of the ent. ID xid.ID `json:"id,omitempty"` // CreatedAt holds the value of the "created_at" field. CreatedAt time.Time `json:"created_at,omitempty"` // UpdatedAt holds the value of the "updated_at" field. UpdatedAt time.Time `json:"updated_at,omitempty"` // Name holds the value of the "name" field. Name string `json:"name,omitempty"` // Slug holds the value of the "slug" field. Slug string `json:"slug,omitempty"` // Description holds the value of the "description" field. Description string `json:"description,omitempty"` // Colour holds the value of the "colour" field. Colour string `json:"colour,omitempty"` // Sort holds the value of the "sort" field. Sort int `json:"sort,omitempty"` // Admin holds the value of the "admin" field. Admin bool `json:"admin,omitempty"` // ParentCategoryID holds the value of the "parent_category_id" field. ParentCategoryID xid.ID `json:"parent_category_id,omitempty"` // CoverImageAssetID holds the value of the "cover_image_asset_id" field. CoverImageAssetID *xid.ID `json:"cover_image_asset_id,omitempty"` // Arbitrary metadata used by clients to store domain specific information. Metadata map[string]interface{} `json:"metadata,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the CategoryQuery when eager-loading is set. Edges CategoryEdges `json:"edges"` selectValues sql.SelectValues } // CategoryEdges holds the relations/edges for other nodes in the graph. type CategoryEdges struct { // Posts holds the value of the posts edge. Posts []*Post `json:"posts,omitempty"` // Optional recursive self reference to the parent category. Parent *Category `json:"parent,omitempty"` // Children holds the value of the children edge. Children []*Category `json:"children,omitempty"` // CoverImage holds the value of the cover_image edge. CoverImage *Asset `json:"cover_image,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. loadedTypes [4]bool } // PostsOrErr returns the Posts value or an error if the edge // was not loaded in eager-loading. func (e CategoryEdges) PostsOrErr() ([]*Post, error) { if e.loadedTypes[0] { return e.Posts, nil } return nil, &NotLoadedError{edge: "posts"} } // ParentOrErr returns the Parent value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e CategoryEdges) ParentOrErr() (*Category, error) { if e.Parent != nil { return e.Parent, nil } else if e.loadedTypes[1] { return nil, &NotFoundError{label: category.Label} } return nil, &NotLoadedError{edge: "parent"} } // ChildrenOrErr returns the Children value or an error if the edge // was not loaded in eager-loading. func (e CategoryEdges) ChildrenOrErr() ([]*Category, error) { if e.loadedTypes[2] { return e.Children, nil } return nil, &NotLoadedError{edge: "children"} } // CoverImageOrErr returns the CoverImage value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e CategoryEdges) CoverImageOrErr() (*Asset, error) { if e.CoverImage != nil { return e.CoverImage, nil } else if e.loadedTypes[3] { return nil, &NotFoundError{label: asset.Label} } return nil, &NotLoadedError{edge: "cover_image"} } // scanValues returns the types for scanning values from sql.Rows. func (*Category) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case category.FieldCoverImageAssetID: values[i] = &sql.NullScanner{S: new(xid.ID)} case category.FieldMetadata: values[i] = new([]byte) case category.FieldAdmin: values[i] = new(sql.NullBool) case category.FieldSort: values[i] = new(sql.NullInt64) case category.FieldName, category.FieldSlug, category.FieldDescription, category.FieldColour: values[i] = new(sql.NullString) case category.FieldCreatedAt, category.FieldUpdatedAt: values[i] = new(sql.NullTime) case category.FieldID, category.FieldParentCategoryID: values[i] = new(xid.ID) default: values[i] = new(sql.UnknownType) } } return values, nil } // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the Category fields. func (_m *Category) assignValues(columns []string, values []any) error { if m, n := len(values), len(columns); m < n { return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) } for i := range columns { switch columns[i] { case category.FieldID: if value, ok := values[i].(*xid.ID); !ok { return fmt.Errorf("unexpected type %T for field id", values[i]) } else if value != nil { _m.ID = *value } case category.FieldCreatedAt: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field created_at", values[i]) } else if value.Valid { _m.CreatedAt = value.Time } case category.FieldUpdatedAt: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field updated_at", values[i]) } else if value.Valid { _m.UpdatedAt = value.Time } case category.FieldName: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field name", values[i]) } else if value.Valid { _m.Name = value.String } case category.FieldSlug: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field slug", values[i]) } else if value.Valid { _m.Slug = value.String } case category.FieldDescription: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field description", values[i]) } else if value.Valid { _m.Description = value.String } case category.FieldColour: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field colour", values[i]) } else if value.Valid { _m.Colour = value.String } case category.FieldSort: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field sort", values[i]) } else if value.Valid { _m.Sort = int(value.Int64) } case category.FieldAdmin: if value, ok := values[i].(*sql.NullBool); !ok { return fmt.Errorf("unexpected type %T for field admin", values[i]) } else if value.Valid { _m.Admin = value.Bool } case category.FieldParentCategoryID: if value, ok := values[i].(*xid.ID); !ok { return fmt.Errorf("unexpected type %T for field parent_category_id", values[i]) } else if value != nil { _m.ParentCategoryID = *value } case category.FieldCoverImageAssetID: if value, ok := values[i].(*sql.NullScanner); !ok { return fmt.Errorf("unexpected type %T for field cover_image_asset_id", values[i]) } else if value.Valid { _m.CoverImageAssetID = new(xid.ID) *_m.CoverImageAssetID = *value.S.(*xid.ID) } case category.FieldMetadata: if value, ok := values[i].(*[]byte); !ok { return fmt.Errorf("unexpected type %T for field metadata", values[i]) } else if value != nil && len(*value) > 0 { if err := json.Unmarshal(*value, &_m.Metadata); err != nil { return fmt.Errorf("unmarshal field metadata: %w", err) } } default: _m.selectValues.Set(columns[i], values[i]) } } return nil } // Value returns the ent.Value that was dynamically selected and assigned to the Category. // This includes values selected through modifiers, order, etc. func (_m *Category) Value(name string) (ent.Value, error) { return _m.selectValues.Get(name) } // QueryPosts queries the "posts" edge of the Category entity. func (_m *Category) QueryPosts() *PostQuery { return NewCategoryClient(_m.config).QueryPosts(_m) } // QueryParent queries the "parent" edge of the Category entity. func (_m *Category) QueryParent() *CategoryQuery { return NewCategoryClient(_m.config).QueryParent(_m) } // QueryChildren queries the "children" edge of the Category entity. func (_m *Category) QueryChildren() *CategoryQuery { return NewCategoryClient(_m.config).QueryChildren(_m) } // QueryCoverImage queries the "cover_image" edge of the Category entity. func (_m *Category) QueryCoverImage() *AssetQuery { return NewCategoryClient(_m.config).QueryCoverImage(_m) } // Update returns a builder for updating this Category. // Note that you need to call Category.Unwrap() before calling this method if this Category // was returned from a transaction, and the transaction was committed or rolled back. func (_m *Category) Update() *CategoryUpdateOne { return NewCategoryClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the Category entity that was returned from a transaction after it was closed, // so that all future queries will be executed through the driver which created the transaction. func (_m *Category) Unwrap() *Category { _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: Category is not a transactional entity") } _m.config.driver = _tx.drv return _m } // String implements the fmt.Stringer. func (_m *Category) String() string { var builder strings.Builder builder.WriteString("Category(") builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("created_at=") builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("updated_at=") builder.WriteString(_m.UpdatedAt.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("name=") builder.WriteString(_m.Name) builder.WriteString(", ") builder.WriteString("slug=") builder.WriteString(_m.Slug) builder.WriteString(", ") builder.WriteString("description=") builder.WriteString(_m.Description) builder.WriteString(", ") builder.WriteString("colour=") builder.WriteString(_m.Colour) builder.WriteString(", ") builder.WriteString("sort=") builder.WriteString(fmt.Sprintf("%v", _m.Sort)) builder.WriteString(", ") builder.WriteString("admin=") builder.WriteString(fmt.Sprintf("%v", _m.Admin)) builder.WriteString(", ") builder.WriteString("parent_category_id=") builder.WriteString(fmt.Sprintf("%v", _m.ParentCategoryID)) builder.WriteString(", ") if v := _m.CoverImageAssetID; v != nil { builder.WriteString("cover_image_asset_id=") builder.WriteString(fmt.Sprintf("%v", *v)) } builder.WriteString(", ") builder.WriteString("metadata=") builder.WriteString(fmt.Sprintf("%v", _m.Metadata)) builder.WriteByte(')') return builder.String() } // Categories is a parsable slice of Category. type Categories []*Category

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Southclaws/storyden'

If you have feedback or need assistance with the MCP directory API, please join our Discord server