mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
feat: move reaction type to setting
This commit is contained in:
@ -4,13 +4,12 @@ import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
func (d *DB) UpsertReaction(ctx context.Context, upsert *store.Reaction) (*store.Reaction, error) {
|
||||
fields := []string{"creator_id", "content_id", "reaction_type"}
|
||||
args := []interface{}{upsert.CreatorID, upsert.ContentID, upsert.ReactionType.String()}
|
||||
args := []interface{}{upsert.CreatorID, upsert.ContentID, upsert.ReactionType}
|
||||
stmt := "INSERT INTO reaction (" + strings.Join(fields, ", ") + ") VALUES (" + placeholders(len(args)) + ") RETURNING id, created_ts"
|
||||
if err := d.db.QueryRowContext(ctx, stmt, args...).Scan(
|
||||
&upsert.ID,
|
||||
@ -55,17 +54,15 @@ func (d *DB) ListReactions(ctx context.Context, find *store.FindReaction) ([]*st
|
||||
list := []*store.Reaction{}
|
||||
for rows.Next() {
|
||||
reaction := &store.Reaction{}
|
||||
var reactionType string
|
||||
if err := rows.Scan(
|
||||
&reaction.ID,
|
||||
&reaction.CreatedTs,
|
||||
&reaction.CreatorID,
|
||||
&reaction.ContentID,
|
||||
&reactionType,
|
||||
&reaction.ReactionType,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reaction.ReactionType = storepb.ReactionType(storepb.ReactionType_value[reactionType])
|
||||
list = append(list, reaction)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user