feat: update

This commit is contained in:
rogeecn
2025-03-22 18:23:39 +08:00
parent 12761e1adb
commit 12d5158ad3
11 changed files with 890 additions and 34 deletions

View File

@@ -1,8 +0,0 @@
package models
// @provider
type migrationsModel struct{}
func (m *migrationsModel) Prepare() error {
return nil
}

View File

@@ -9,18 +9,18 @@ import (
var db *sql.DB
var Medias *mediasModel
var Migrations *migrationsModel
var Posts *postsModel
// @provider(model)
type models struct {
db *sql.DB
medias *mediasModel
migrations *migrationsModel
db *sql.DB
medias *mediasModel
posts *postsModel
}
func (m *models) Prepare() error {
db = m.db
Medias = m.medias
Migrations = m.migrations
Posts = m.posts
return nil
}

8
app/models/posts.go Normal file
View File

@@ -0,0 +1,8 @@
package models
// @provider
type postsModel struct{}
func (m *postsModel) Prepare() error {
return nil
}

View File

@@ -20,22 +20,15 @@ func Provide(opts ...opt.Option) error {
}); err != nil {
return err
}
if err := container.Container.Provide(func() (*migrationsModel, error) {
obj := &migrationsModel{}
return obj, nil
}); err != nil {
return err
}
if err := container.Container.Provide(func(
db *sql.DB,
medias *mediasModel,
migrations *migrationsModel,
posts *postsModel,
) (contracts.Initial, error) {
obj := &models{
db: db,
medias: medias,
migrations: migrations,
db: db,
medias: medias,
posts: posts,
}
if err := obj.Prepare(); err != nil {
return nil, err
@@ -45,5 +38,12 @@ func Provide(opts ...opt.Option) error {
}, atom.GroupInitial); err != nil {
return err
}
if err := container.Container.Provide(func() (*postsModel, error) {
obj := &postsModel{}
return obj, nil
}); err != nil {
return err
}
return nil
}

View File

@@ -0,0 +1,652 @@
// Code generated by go-enum DO NOT EDIT.
// Version: -
// Revision: -
// Build Date: -
// Built By: -
package fields
import (
"database/sql/driver"
"errors"
"fmt"
"strconv"
"strings"
)
const (
// MediaAssetTypeUnknown is a MediaAssetType of type Unknown.
MediaAssetTypeUnknown MediaAssetType = "unknown"
// MediaAssetTypePoster is a MediaAssetType of type Poster.
MediaAssetTypePoster MediaAssetType = "poster"
// MediaAssetTypeImage is a MediaAssetType of type Image.
MediaAssetTypeImage MediaAssetType = "image"
// MediaAssetTypeVideo is a MediaAssetType of type Video.
MediaAssetTypeVideo MediaAssetType = "video"
// MediaAssetTypeAudio is a MediaAssetType of type Audio.
MediaAssetTypeAudio MediaAssetType = "audio"
// MediaAssetTypeDocument is a MediaAssetType of type Document.
MediaAssetTypeDocument MediaAssetType = "document"
// MediaAssetTypeOther is a MediaAssetType of type Other.
MediaAssetTypeOther MediaAssetType = "other"
)
var ErrInvalidMediaAssetType = fmt.Errorf("not a valid MediaAssetType, try [%s]", strings.Join(_MediaAssetTypeNames, ", "))
var _MediaAssetTypeNames = []string{
string(MediaAssetTypeUnknown),
string(MediaAssetTypePoster),
string(MediaAssetTypeImage),
string(MediaAssetTypeVideo),
string(MediaAssetTypeAudio),
string(MediaAssetTypeDocument),
string(MediaAssetTypeOther),
}
// MediaAssetTypeNames returns a list of possible string values of MediaAssetType.
func MediaAssetTypeNames() []string {
tmp := make([]string, len(_MediaAssetTypeNames))
copy(tmp, _MediaAssetTypeNames)
return tmp
}
// MediaAssetTypeValues returns a list of the values for MediaAssetType
func MediaAssetTypeValues() []MediaAssetType {
return []MediaAssetType{
MediaAssetTypeUnknown,
MediaAssetTypePoster,
MediaAssetTypeImage,
MediaAssetTypeVideo,
MediaAssetTypeAudio,
MediaAssetTypeDocument,
MediaAssetTypeOther,
}
}
// String implements the Stringer interface.
func (x MediaAssetType) String() string {
return string(x)
}
// IsValid provides a quick way to determine if the typed value is
// part of the allowed enumerated values
func (x MediaAssetType) IsValid() bool {
_, err := ParseMediaAssetType(string(x))
return err == nil
}
var _MediaAssetTypeValue = map[string]MediaAssetType{
"unknown": MediaAssetTypeUnknown,
"poster": MediaAssetTypePoster,
"image": MediaAssetTypeImage,
"video": MediaAssetTypeVideo,
"audio": MediaAssetTypeAudio,
"document": MediaAssetTypeDocument,
"other": MediaAssetTypeOther,
}
// ParseMediaAssetType attempts to convert a string to a MediaAssetType.
func ParseMediaAssetType(name string) (MediaAssetType, error) {
if x, ok := _MediaAssetTypeValue[name]; ok {
return x, nil
}
return MediaAssetType(""), fmt.Errorf("%s is %w", name, ErrInvalidMediaAssetType)
}
var errMediaAssetTypeNilPtr = errors.New("value pointer is nil") // one per type for package clashes
// Scan implements the Scanner interface.
func (x *MediaAssetType) Scan(value interface{}) (err error) {
if value == nil {
*x = MediaAssetType("")
return
}
// A wider range of scannable types.
// driver.Value values at the top of the list for expediency
switch v := value.(type) {
case string:
*x, err = ParseMediaAssetType(v)
case []byte:
*x, err = ParseMediaAssetType(string(v))
case MediaAssetType:
*x = v
case *MediaAssetType:
if v == nil {
return errMediaAssetTypeNilPtr
}
*x = *v
case *string:
if v == nil {
return errMediaAssetTypeNilPtr
}
*x, err = ParseMediaAssetType(*v)
default:
return errors.New("invalid type for MediaAssetType")
}
return
}
// Value implements the driver Valuer interface.
func (x MediaAssetType) Value() (driver.Value, error) {
return x.String(), nil
}
// Set implements the Golang flag.Value interface func.
func (x *MediaAssetType) Set(val string) error {
v, err := ParseMediaAssetType(val)
*x = v
return err
}
// Get implements the Golang flag.Getter interface func.
func (x *MediaAssetType) Get() interface{} {
return *x
}
// Type implements the github.com/spf13/pFlag Value interface.
func (x *MediaAssetType) Type() string {
return "MediaAssetType"
}
type NullMediaAssetType struct {
MediaAssetType MediaAssetType
Valid bool
}
func NewNullMediaAssetType(val interface{}) (x NullMediaAssetType) {
err := x.Scan(val) // yes, we ignore this error, it will just be an invalid value.
_ = err // make any errcheck linters happy
return
}
// Scan implements the Scanner interface.
func (x *NullMediaAssetType) Scan(value interface{}) (err error) {
if value == nil {
x.MediaAssetType, x.Valid = MediaAssetType(""), false
return
}
err = x.MediaAssetType.Scan(value)
x.Valid = (err == nil)
return
}
// Value implements the driver Valuer interface.
func (x NullMediaAssetType) Value() (driver.Value, error) {
if !x.Valid {
return nil, nil
}
// driver.Value accepts int64 for int values.
return string(x.MediaAssetType), nil
}
type NullMediaAssetTypeStr struct {
NullMediaAssetType
}
func NewNullMediaAssetTypeStr(val interface{}) (x NullMediaAssetTypeStr) {
x.Scan(val) // yes, we ignore this error, it will just be an invalid value.
return
}
// Value implements the driver Valuer interface.
func (x NullMediaAssetTypeStr) Value() (driver.Value, error) {
if !x.Valid {
return nil, nil
}
return x.MediaAssetType.String(), nil
}
const (
// PostStatusDraft is a PostStatus of type Draft.
PostStatusDraft PostStatus = iota
// PostStatusPublished is a PostStatus of type Published.
PostStatusPublished
)
var ErrInvalidPostStatus = fmt.Errorf("not a valid PostStatus, try [%s]", strings.Join(_PostStatusNames, ", "))
const _PostStatusName = "draftpublished"
var _PostStatusNames = []string{
_PostStatusName[0:5],
_PostStatusName[5:14],
}
// PostStatusNames returns a list of possible string values of PostStatus.
func PostStatusNames() []string {
tmp := make([]string, len(_PostStatusNames))
copy(tmp, _PostStatusNames)
return tmp
}
// PostStatusValues returns a list of the values for PostStatus
func PostStatusValues() []PostStatus {
return []PostStatus{
PostStatusDraft,
PostStatusPublished,
}
}
var _PostStatusMap = map[PostStatus]string{
PostStatusDraft: _PostStatusName[0:5],
PostStatusPublished: _PostStatusName[5:14],
}
// String implements the Stringer interface.
func (x PostStatus) String() string {
if str, ok := _PostStatusMap[x]; ok {
return str
}
return fmt.Sprintf("PostStatus(%d)", x)
}
// IsValid provides a quick way to determine if the typed value is
// part of the allowed enumerated values
func (x PostStatus) IsValid() bool {
_, ok := _PostStatusMap[x]
return ok
}
var _PostStatusValue = map[string]PostStatus{
_PostStatusName[0:5]: PostStatusDraft,
_PostStatusName[5:14]: PostStatusPublished,
}
// ParsePostStatus attempts to convert a string to a PostStatus.
func ParsePostStatus(name string) (PostStatus, error) {
if x, ok := _PostStatusValue[name]; ok {
return x, nil
}
return PostStatus(0), fmt.Errorf("%s is %w", name, ErrInvalidPostStatus)
}
var errPostStatusNilPtr = errors.New("value pointer is nil") // one per type for package clashes
// Scan implements the Scanner interface.
func (x *PostStatus) Scan(value interface{}) (err error) {
if value == nil {
*x = PostStatus(0)
return
}
// A wider range of scannable types.
// driver.Value values at the top of the list for expediency
switch v := value.(type) {
case int64:
*x = PostStatus(v)
case string:
*x, err = ParsePostStatus(v)
if err != nil {
// try parsing the integer value as a string
if val, verr := strconv.Atoi(v); verr == nil {
*x, err = PostStatus(val), nil
}
}
case []byte:
*x, err = ParsePostStatus(string(v))
if err != nil {
// try parsing the integer value as a string
if val, verr := strconv.Atoi(string(v)); verr == nil {
*x, err = PostStatus(val), nil
}
}
case PostStatus:
*x = v
case int:
*x = PostStatus(v)
case *PostStatus:
if v == nil {
return errPostStatusNilPtr
}
*x = *v
case uint:
*x = PostStatus(v)
case uint64:
*x = PostStatus(v)
case *int:
if v == nil {
return errPostStatusNilPtr
}
*x = PostStatus(*v)
case *int64:
if v == nil {
return errPostStatusNilPtr
}
*x = PostStatus(*v)
case float64: // json marshals everything as a float64 if it's a number
*x = PostStatus(v)
case *float64: // json marshals everything as a float64 if it's a number
if v == nil {
return errPostStatusNilPtr
}
*x = PostStatus(*v)
case *uint:
if v == nil {
return errPostStatusNilPtr
}
*x = PostStatus(*v)
case *uint64:
if v == nil {
return errPostStatusNilPtr
}
*x = PostStatus(*v)
case *string:
if v == nil {
return errPostStatusNilPtr
}
*x, err = ParsePostStatus(*v)
if err != nil {
// try parsing the integer value as a string
if val, verr := strconv.Atoi(*v); verr == nil {
*x, err = PostStatus(val), nil
}
}
}
return
}
// Value implements the driver Valuer interface.
func (x PostStatus) Value() (driver.Value, error) {
return int64(x), nil
}
// Set implements the Golang flag.Value interface func.
func (x *PostStatus) Set(val string) error {
v, err := ParsePostStatus(val)
*x = v
return err
}
// Get implements the Golang flag.Getter interface func.
func (x *PostStatus) Get() interface{} {
return *x
}
// Type implements the github.com/spf13/pFlag Value interface.
func (x *PostStatus) Type() string {
return "PostStatus"
}
type NullPostStatus struct {
PostStatus PostStatus
Valid bool
}
func NewNullPostStatus(val interface{}) (x NullPostStatus) {
x.Scan(val) // yes, we ignore this error, it will just be an invalid value.
return
}
// Scan implements the Scanner interface.
func (x *NullPostStatus) Scan(value interface{}) (err error) {
if value == nil {
x.PostStatus, x.Valid = PostStatus(0), false
return
}
err = x.PostStatus.Scan(value)
x.Valid = (err == nil)
return
}
// Value implements the driver Valuer interface.
func (x NullPostStatus) Value() (driver.Value, error) {
if !x.Valid {
return nil, nil
}
// driver.Value accepts int64 for int values.
return int64(x.PostStatus), nil
}
type NullPostStatusStr struct {
NullPostStatus
}
func NewNullPostStatusStr(val interface{}) (x NullPostStatusStr) {
x.Scan(val) // yes, we ignore this error, it will just be an invalid value.
return
}
// Value implements the driver Valuer interface.
func (x NullPostStatusStr) Value() (driver.Value, error) {
if !x.Valid {
return nil, nil
}
return x.PostStatus.String(), nil
}
const (
// PostTypeArticle is a PostType of type Article.
PostTypeArticle PostType = iota
// PostTypePicture is a PostType of type Picture.
PostTypePicture
// PostTypeVideo is a PostType of type Video.
PostTypeVideo
// PostTypeAudio is a PostType of type Audio.
PostTypeAudio
)
var ErrInvalidPostType = fmt.Errorf("not a valid PostType, try [%s]", strings.Join(_PostTypeNames, ", "))
const _PostTypeName = "ArticlePictureVideoAudio"
var _PostTypeNames = []string{
_PostTypeName[0:7],
_PostTypeName[7:14],
_PostTypeName[14:19],
_PostTypeName[19:24],
}
// PostTypeNames returns a list of possible string values of PostType.
func PostTypeNames() []string {
tmp := make([]string, len(_PostTypeNames))
copy(tmp, _PostTypeNames)
return tmp
}
// PostTypeValues returns a list of the values for PostType
func PostTypeValues() []PostType {
return []PostType{
PostTypeArticle,
PostTypePicture,
PostTypeVideo,
PostTypeAudio,
}
}
var _PostTypeMap = map[PostType]string{
PostTypeArticle: _PostTypeName[0:7],
PostTypePicture: _PostTypeName[7:14],
PostTypeVideo: _PostTypeName[14:19],
PostTypeAudio: _PostTypeName[19:24],
}
// String implements the Stringer interface.
func (x PostType) String() string {
if str, ok := _PostTypeMap[x]; ok {
return str
}
return fmt.Sprintf("PostType(%d)", x)
}
// IsValid provides a quick way to determine if the typed value is
// part of the allowed enumerated values
func (x PostType) IsValid() bool {
_, ok := _PostTypeMap[x]
return ok
}
var _PostTypeValue = map[string]PostType{
_PostTypeName[0:7]: PostTypeArticle,
_PostTypeName[7:14]: PostTypePicture,
_PostTypeName[14:19]: PostTypeVideo,
_PostTypeName[19:24]: PostTypeAudio,
}
// ParsePostType attempts to convert a string to a PostType.
func ParsePostType(name string) (PostType, error) {
if x, ok := _PostTypeValue[name]; ok {
return x, nil
}
return PostType(0), fmt.Errorf("%s is %w", name, ErrInvalidPostType)
}
var errPostTypeNilPtr = errors.New("value pointer is nil") // one per type for package clashes
// Scan implements the Scanner interface.
func (x *PostType) Scan(value interface{}) (err error) {
if value == nil {
*x = PostType(0)
return
}
// A wider range of scannable types.
// driver.Value values at the top of the list for expediency
switch v := value.(type) {
case int64:
*x = PostType(v)
case string:
*x, err = ParsePostType(v)
if err != nil {
// try parsing the integer value as a string
if val, verr := strconv.Atoi(v); verr == nil {
*x, err = PostType(val), nil
}
}
case []byte:
*x, err = ParsePostType(string(v))
if err != nil {
// try parsing the integer value as a string
if val, verr := strconv.Atoi(string(v)); verr == nil {
*x, err = PostType(val), nil
}
}
case PostType:
*x = v
case int:
*x = PostType(v)
case *PostType:
if v == nil {
return errPostTypeNilPtr
}
*x = *v
case uint:
*x = PostType(v)
case uint64:
*x = PostType(v)
case *int:
if v == nil {
return errPostTypeNilPtr
}
*x = PostType(*v)
case *int64:
if v == nil {
return errPostTypeNilPtr
}
*x = PostType(*v)
case float64: // json marshals everything as a float64 if it's a number
*x = PostType(v)
case *float64: // json marshals everything as a float64 if it's a number
if v == nil {
return errPostTypeNilPtr
}
*x = PostType(*v)
case *uint:
if v == nil {
return errPostTypeNilPtr
}
*x = PostType(*v)
case *uint64:
if v == nil {
return errPostTypeNilPtr
}
*x = PostType(*v)
case *string:
if v == nil {
return errPostTypeNilPtr
}
*x, err = ParsePostType(*v)
if err != nil {
// try parsing the integer value as a string
if val, verr := strconv.Atoi(*v); verr == nil {
*x, err = PostType(val), nil
}
}
}
return
}
// Value implements the driver Valuer interface.
func (x PostType) Value() (driver.Value, error) {
return int64(x), nil
}
// Set implements the Golang flag.Value interface func.
func (x *PostType) Set(val string) error {
v, err := ParsePostType(val)
*x = v
return err
}
// Get implements the Golang flag.Getter interface func.
func (x *PostType) Get() interface{} {
return *x
}
// Type implements the github.com/spf13/pFlag Value interface.
func (x *PostType) Type() string {
return "PostType"
}
type NullPostType struct {
PostType PostType
Valid bool
}
func NewNullPostType(val interface{}) (x NullPostType) {
x.Scan(val) // yes, we ignore this error, it will just be an invalid value.
return
}
// Scan implements the Scanner interface.
func (x *NullPostType) Scan(value interface{}) (err error) {
if value == nil {
x.PostType, x.Valid = PostType(0), false
return
}
err = x.PostType.Scan(value)
x.Valid = (err == nil)
return
}
// Value implements the driver Valuer interface.
func (x NullPostType) Value() (driver.Value, error) {
if !x.Valid {
return nil, nil
}
// driver.Value accepts int64 for int values.
return int64(x.PostType), nil
}
type NullPostTypeStr struct {
NullPostType
}
func NewNullPostTypeStr(val interface{}) (x NullPostTypeStr) {
x.Scan(val) // yes, we ignore this error, it will just be an invalid value.
return
}
// Value implements the driver Valuer interface.
func (x NullPostTypeStr) Value() (driver.Value, error) {
if !x.Valid {
return nil, nil
}
return x.PostType.String(), nil
}

27
database/fields/posts.go Normal file
View File

@@ -0,0 +1,27 @@
package fields
type MediaAsset struct {
Type MediaAssetType `json:"type"`
Media int64 `json:"media"`
Mark *string `json:"mark,omitempty"`
}
// swagger:enum MediaAssetType
// ENUM(
// Unknown = "unknown",
// Poster = "poster",
// Image = "image",
// Video = "video",
// Audio = "audio",
// Document = "document",
// Other = "other"
// )
type MediaAssetType string
// swagger:enum PostStatus
// ENUM( draft, published )
type PostStatus int16
// swagger:enum PostType
// ENUM( Article, Picture, Video, Audio)
type PostType int16

View File

@@ -0,0 +1,25 @@
-- +goose Up
-- +goose StatementBegin
CREATE TABLE posts(
id SERIAL8 PRIMARY KEY,
created_at timestamp NOT NULL DEFAULT now(),
updated_at timestamp NOT NULL DEFAULT now(),
deleted_at timestamp,
status int2 NOT NULL DEFAULT 0,
title varchar(128) NOT NULL,
description varchar(256) NOT NULL,
content text NOT NULL,
price int8 NOT NULL DEFAULT 0,
discount int2 NOT NULL DEFAULT 100,
views int8 NOT NULL DEFAULT 0,
likes int8 NOT NULL DEFAULT 0,
tags jsonb DEFAULT '{}' ::jsonb,
assets jsonb DEFAULT '{}' ::jsonb
);
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE posts;
-- +goose StatementEnd

View File

@@ -0,0 +1,30 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package model
import (
"quyun/database/fields"
"time"
)
type Posts struct {
ID int64 `sql:"primary_key" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt *time.Time `json:"deleted_at"`
Status fields.PostStatus `json:"status"`
Title string `json:"title"`
Description string `json:"description"`
Content string `json:"content"`
Price int64 `json:"price"`
Discount int16 `json:"discount"`
Views int64 `json:"views"`
Likes int64 `json:"likes"`
Tags fields.Json[[]string] `json:"tags"`
Assets fields.Json[[]fields.MediaAsset] `json:"assets"`
}

View File

@@ -0,0 +1,114 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package table
import (
"github.com/go-jet/jet/v2/postgres"
)
var Posts = newPostsTable("public", "posts", "")
type postsTable struct {
postgres.Table
// Columns
ID postgres.ColumnInteger
CreatedAt postgres.ColumnTimestamp
UpdatedAt postgres.ColumnTimestamp
DeletedAt postgres.ColumnTimestamp
Status postgres.ColumnInteger
Title postgres.ColumnString
Description postgres.ColumnString
Content postgres.ColumnString
Price postgres.ColumnInteger
Discount postgres.ColumnInteger
Views postgres.ColumnInteger
Likes postgres.ColumnInteger
Tags postgres.ColumnString
Assets postgres.ColumnString
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
}
type PostsTable struct {
postsTable
EXCLUDED postsTable
}
// AS creates new PostsTable with assigned alias
func (a PostsTable) AS(alias string) *PostsTable {
return newPostsTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new PostsTable with assigned schema name
func (a PostsTable) FromSchema(schemaName string) *PostsTable {
return newPostsTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new PostsTable with assigned table prefix
func (a PostsTable) WithPrefix(prefix string) *PostsTable {
return newPostsTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new PostsTable with assigned table suffix
func (a PostsTable) WithSuffix(suffix string) *PostsTable {
return newPostsTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newPostsTable(schemaName, tableName, alias string) *PostsTable {
return &PostsTable{
postsTable: newPostsTableImpl(schemaName, tableName, alias),
EXCLUDED: newPostsTableImpl("", "excluded", ""),
}
}
func newPostsTableImpl(schemaName, tableName, alias string) postsTable {
var (
IDColumn = postgres.IntegerColumn("id")
CreatedAtColumn = postgres.TimestampColumn("created_at")
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
DeletedAtColumn = postgres.TimestampColumn("deleted_at")
StatusColumn = postgres.IntegerColumn("status")
TitleColumn = postgres.StringColumn("title")
DescriptionColumn = postgres.StringColumn("description")
ContentColumn = postgres.StringColumn("content")
PriceColumn = postgres.IntegerColumn("price")
DiscountColumn = postgres.IntegerColumn("discount")
ViewsColumn = postgres.IntegerColumn("views")
LikesColumn = postgres.IntegerColumn("likes")
TagsColumn = postgres.StringColumn("tags")
AssetsColumn = postgres.StringColumn("assets")
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, StatusColumn, TitleColumn, DescriptionColumn, ContentColumn, PriceColumn, DiscountColumn, ViewsColumn, LikesColumn, TagsColumn, AssetsColumn}
mutableColumns = postgres.ColumnList{CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, StatusColumn, TitleColumn, DescriptionColumn, ContentColumn, PriceColumn, DiscountColumn, ViewsColumn, LikesColumn, TagsColumn, AssetsColumn}
)
return postsTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
ID: IDColumn,
CreatedAt: CreatedAtColumn,
UpdatedAt: UpdatedAtColumn,
DeletedAt: DeletedAtColumn,
Status: StatusColumn,
Title: TitleColumn,
Description: DescriptionColumn,
Content: ContentColumn,
Price: PriceColumn,
Discount: DiscountColumn,
Views: ViewsColumn,
Likes: LikesColumn,
Tags: TagsColumn,
Assets: AssetsColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
}
}

View File

@@ -12,4 +12,5 @@ package table
func UseSchema(schema string) {
Medias = Medias.FromSchema(schema)
Migrations = Migrations.FromSchema(schema)
Posts = Posts.FromSchema(schema)
}

View File

@@ -1,11 +1,18 @@
ignores:
- migrations
- river_leader
- river_job
- river_client
- river_client_queue
- river_queue
# types:
# users: # table name
# meta: UserMeta
# meta: Json[UserMeta]
jet:
- river_leader
- river_job
- river_client
- river_client_queue
- river_queue
model:
- migrations
types:
# users: # table name
# meta: UserMeta
# meta: Json[UserMeta]
posts:
status: PostStatus
assets: Json[[]MediaAsset]
tags: Json[[]string]
meta: PostMeta