chore: add CreatedTs field to MemoCreate (#1073)

This commit is contained in:
boojack 2023-02-11 21:32:42 +08:00 committed by GitHub
parent 799fb058b4
commit bdf0c44246
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -46,7 +46,8 @@ type Memo struct {
type MemoCreate struct {
// Standard fields
CreatorID int `json:"-"`
CreatorID int `json:"-"`
CreatedTs *int64 `json:"createdTs"`
// Domain specific fields
Visibility Visibility `json:"visibility"`

View file

@ -217,6 +217,10 @@ func createMemoRaw(ctx context.Context, tx *sql.Tx, create *api.MemoCreate) (*me
args := []interface{}{create.CreatorID, create.Content, create.Visibility}
placeholder := []string{"?", "?", "?"}
if v := create.CreatedTs; v != nil {
set, args, placeholder = append(set, "created_ts"), append(args, *v), append(placeholder, "?")
}
query := `
INSERT INTO memo (
` + strings.Join(set, ", ") + `