tweet

package
v0.0.0-...-8b1a3a3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PageOptionForQueryOrderByCreatedAtDesc

type PageOptionForQueryOrderByCreatedAtDesc struct {
	ID        string
	CreatedAt time.Time
}

type Store

type Store interface {
	TableName() string
	Insert(ctx context.Context, tweet *Tweet) (time.Time, error)
	Update(ctx context.Context, id string) (*spanner.CommitResponse, error)
	UpdateDML(ctx context.Context, id string) (time.Time, error)
	Delete(ctx context.Context, id string) error
	Get(ctx context.Context, key spanner.Key) (*Tweet, error)
	Query(ctx context.Context, limit int) ([]*Tweet, error)
	QueryHeavy(ctx context.Context) ([]*Tweet, error)
	QueryAll(ctx context.Context) (int, error)
	QueryResultStruct(ctx context.Context, orderByAsc bool, limit int, tb *spanner.TimestampBound) ([]*TweetIDAndAuthor, error)
	QueryOrderByCreatedAtDesc(ctx context.Context, startShard int, endShard int, pageOption *PageOptionForQueryOrderByCreatedAtDesc, limit int) ([]*Tweet, error)
	QueryRandom(ctx context.Context) error
}

Store is TweetTable Functions

func NewStore

func NewStore(sc *spanner.Client) Store

NewStore is New TweetStore

type Tweet

type Tweet struct {
	TweetID       string
	Author        string
	Content       string
	ContentLength int64 // generated columns
	Favos         []string
	Sort          int64
	ShardID       int64
	CreatedAt     time.Time
	UpdatedAt     time.Time
	CommitedAt    time.Time // allow_commit_timestamp
	SchemaVersion int64
}

Tweet is TweetTable Row

func (*Tweet) ToInsertOrUpdateMap

func (t *Tweet) ToInsertOrUpdateMap() map[string]interface{}

ToInsertOrUpdateMap is Tweet structから、InsertOrUpdateができないColumnを取り除いたmapを作る

InsertOrUpdateができないColumnとしては、generated columnsで生成されるcolumnがある

type TweetIDAndAuthor

type TweetIDAndAuthor struct {
	ID     string `spanner:"Id"`
	Author string
}

TweetIDAndAuthor is StructのResponseの確認用に作ったStruct

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL