Skip to main content
Glama

Storyden

by Southclaws
Mozilla Public License 2.0
227
asset.go10.7 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/account" "github.com/Southclaws/storyden/internal/ent/asset" "github.com/rs/xid" ) // Asset is the model entity for the Asset schema. type Asset 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"` // Filename holds the value of the "filename" field. Filename string `json:"filename,omitempty"` // Size holds the value of the "size" field. Size int `json:"size,omitempty"` // MimeType holds the value of the "mime_type" field. MimeType string `json:"mime_type,omitempty"` // Metadata holds the value of the "metadata" field. Metadata map[string]interface{} `json:"metadata,omitempty"` // AccountID holds the value of the "account_id" field. AccountID xid.ID `json:"account_id,omitempty"` // ParentAssetID holds the value of the "parent_asset_id" field. ParentAssetID *xid.ID `json:"parent_asset_id,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the AssetQuery when eager-loading is set. Edges AssetEdges `json:"edges"` selectValues sql.SelectValues } // AssetEdges holds the relations/edges for other nodes in the graph. type AssetEdges struct { // Posts holds the value of the posts edge. Posts []*Post `json:"posts,omitempty"` // Nodes holds the value of the nodes edge. Nodes []*Node `json:"nodes,omitempty"` // Links holds the value of the links edge. Links []*Link `json:"links,omitempty"` // Owner holds the value of the owner edge. Owner *Account `json:"owner,omitempty"` // Parent holds the value of the parent edge. Parent *Asset `json:"parent,omitempty"` // Assets holds the value of the assets edge. Assets []*Asset `json:"assets,omitempty"` // Event holds the value of the event edge. Event []*Event `json:"event,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. loadedTypes [7]bool } // PostsOrErr returns the Posts value or an error if the edge // was not loaded in eager-loading. func (e AssetEdges) PostsOrErr() ([]*Post, error) { if e.loadedTypes[0] { return e.Posts, nil } return nil, &NotLoadedError{edge: "posts"} } // NodesOrErr returns the Nodes value or an error if the edge // was not loaded in eager-loading. func (e AssetEdges) NodesOrErr() ([]*Node, error) { if e.loadedTypes[1] { return e.Nodes, nil } return nil, &NotLoadedError{edge: "nodes"} } // LinksOrErr returns the Links value or an error if the edge // was not loaded in eager-loading. func (e AssetEdges) LinksOrErr() ([]*Link, error) { if e.loadedTypes[2] { return e.Links, nil } return nil, &NotLoadedError{edge: "links"} } // OwnerOrErr returns the Owner value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e AssetEdges) OwnerOrErr() (*Account, error) { if e.Owner != nil { return e.Owner, nil } else if e.loadedTypes[3] { return nil, &NotFoundError{label: account.Label} } return nil, &NotLoadedError{edge: "owner"} } // 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 AssetEdges) ParentOrErr() (*Asset, error) { if e.Parent != nil { return e.Parent, nil } else if e.loadedTypes[4] { return nil, &NotFoundError{label: asset.Label} } return nil, &NotLoadedError{edge: "parent"} } // AssetsOrErr returns the Assets value or an error if the edge // was not loaded in eager-loading. func (e AssetEdges) AssetsOrErr() ([]*Asset, error) { if e.loadedTypes[5] { return e.Assets, nil } return nil, &NotLoadedError{edge: "assets"} } // EventOrErr returns the Event value or an error if the edge // was not loaded in eager-loading. func (e AssetEdges) EventOrErr() ([]*Event, error) { if e.loadedTypes[6] { return e.Event, nil } return nil, &NotLoadedError{edge: "event"} } // scanValues returns the types for scanning values from sql.Rows. func (*Asset) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case asset.FieldParentAssetID: values[i] = &sql.NullScanner{S: new(xid.ID)} case asset.FieldMetadata: values[i] = new([]byte) case asset.FieldSize: values[i] = new(sql.NullInt64) case asset.FieldFilename, asset.FieldMimeType: values[i] = new(sql.NullString) case asset.FieldCreatedAt, asset.FieldUpdatedAt: values[i] = new(sql.NullTime) case asset.FieldID, asset.FieldAccountID: 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 Asset fields. func (_m *Asset) 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 asset.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 asset.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 asset.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 asset.FieldFilename: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field filename", values[i]) } else if value.Valid { _m.Filename = value.String } case asset.FieldSize: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field size", values[i]) } else if value.Valid { _m.Size = int(value.Int64) } case asset.FieldMimeType: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field mime_type", values[i]) } else if value.Valid { _m.MimeType = value.String } case asset.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) } } case asset.FieldAccountID: if value, ok := values[i].(*xid.ID); !ok { return fmt.Errorf("unexpected type %T for field account_id", values[i]) } else if value != nil { _m.AccountID = *value } case asset.FieldParentAssetID: if value, ok := values[i].(*sql.NullScanner); !ok { return fmt.Errorf("unexpected type %T for field parent_asset_id", values[i]) } else if value.Valid { _m.ParentAssetID = new(xid.ID) *_m.ParentAssetID = *value.S.(*xid.ID) } default: _m.selectValues.Set(columns[i], values[i]) } } return nil } // Value returns the ent.Value that was dynamically selected and assigned to the Asset. // This includes values selected through modifiers, order, etc. func (_m *Asset) Value(name string) (ent.Value, error) { return _m.selectValues.Get(name) } // QueryPosts queries the "posts" edge of the Asset entity. func (_m *Asset) QueryPosts() *PostQuery { return NewAssetClient(_m.config).QueryPosts(_m) } // QueryNodes queries the "nodes" edge of the Asset entity. func (_m *Asset) QueryNodes() *NodeQuery { return NewAssetClient(_m.config).QueryNodes(_m) } // QueryLinks queries the "links" edge of the Asset entity. func (_m *Asset) QueryLinks() *LinkQuery { return NewAssetClient(_m.config).QueryLinks(_m) } // QueryOwner queries the "owner" edge of the Asset entity. func (_m *Asset) QueryOwner() *AccountQuery { return NewAssetClient(_m.config).QueryOwner(_m) } // QueryParent queries the "parent" edge of the Asset entity. func (_m *Asset) QueryParent() *AssetQuery { return NewAssetClient(_m.config).QueryParent(_m) } // QueryAssets queries the "assets" edge of the Asset entity. func (_m *Asset) QueryAssets() *AssetQuery { return NewAssetClient(_m.config).QueryAssets(_m) } // QueryEvent queries the "event" edge of the Asset entity. func (_m *Asset) QueryEvent() *EventQuery { return NewAssetClient(_m.config).QueryEvent(_m) } // Update returns a builder for updating this Asset. // Note that you need to call Asset.Unwrap() before calling this method if this Asset // was returned from a transaction, and the transaction was committed or rolled back. func (_m *Asset) Update() *AssetUpdateOne { return NewAssetClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the Asset 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 *Asset) Unwrap() *Asset { _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: Asset is not a transactional entity") } _m.config.driver = _tx.drv return _m } // String implements the fmt.Stringer. func (_m *Asset) String() string { var builder strings.Builder builder.WriteString("Asset(") 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("filename=") builder.WriteString(_m.Filename) builder.WriteString(", ") builder.WriteString("size=") builder.WriteString(fmt.Sprintf("%v", _m.Size)) builder.WriteString(", ") builder.WriteString("mime_type=") builder.WriteString(_m.MimeType) builder.WriteString(", ") builder.WriteString("metadata=") builder.WriteString(fmt.Sprintf("%v", _m.Metadata)) builder.WriteString(", ") builder.WriteString("account_id=") builder.WriteString(fmt.Sprintf("%v", _m.AccountID)) builder.WriteString(", ") if v := _m.ParentAssetID; v != nil { builder.WriteString("parent_asset_id=") builder.WriteString(fmt.Sprintf("%v", *v)) } builder.WriteByte(')') return builder.String() } // Assets is a parsable slice of Asset. type Assets []*Asset

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