mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
refactor: update resource id naming
This commit is contained in:
@@ -10,9 +10,9 @@ import (
|
||||
)
|
||||
|
||||
func (d *DB) CreateMemo(ctx context.Context, create *store.Memo) (*store.Memo, error) {
|
||||
fields := []string{"`resource_name`", "`creator_id`", "`content`", "`visibility`"}
|
||||
fields := []string{"`uid`", "`creator_id`", "`content`", "`visibility`"}
|
||||
placeholder := []string{"?", "?", "?", "?"}
|
||||
args := []any{create.ResourceName, create.CreatorID, create.Content, create.Visibility}
|
||||
args := []any{create.UID, create.CreatorID, create.Content, create.Visibility}
|
||||
|
||||
stmt := "INSERT INTO `memo` (" + strings.Join(fields, ", ") + ") VALUES (" + strings.Join(placeholder, ", ") + ") RETURNING `id`, `created_ts`, `updated_ts`, `row_status`"
|
||||
if err := d.db.QueryRowContext(ctx, stmt, args...).Scan(
|
||||
@@ -33,8 +33,8 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
|
||||
if v := find.ID; v != nil {
|
||||
where, args = append(where, "`memo`.`id` = ?"), append(args, *v)
|
||||
}
|
||||
if v := find.ResourceName; v != nil {
|
||||
where, args = append(where, "`memo`.`resource_name` = ?"), append(args, *v)
|
||||
if v := find.UID; v != nil {
|
||||
where, args = append(where, "`memo`.`uid` = ?"), append(args, *v)
|
||||
}
|
||||
if v := find.CreatorID; v != nil {
|
||||
where, args = append(where, "`memo`.`creator_id` = ?"), append(args, *v)
|
||||
@@ -84,7 +84,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
|
||||
|
||||
fields := []string{
|
||||
"`memo`.`id` AS `id`",
|
||||
"`memo`.`resource_name` AS `resource_name`",
|
||||
"`memo`.`uid` AS `uid`",
|
||||
"`memo`.`creator_id` AS `creator_id`",
|
||||
"`memo`.`created_ts` AS `created_ts`",
|
||||
"`memo`.`updated_ts` AS `updated_ts`",
|
||||
@@ -120,7 +120,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
|
||||
var memo store.Memo
|
||||
dests := []any{
|
||||
&memo.ID,
|
||||
&memo.ResourceName,
|
||||
&memo.UID,
|
||||
&memo.CreatorID,
|
||||
&memo.CreatedTs,
|
||||
&memo.UpdatedTs,
|
||||
@@ -147,8 +147,8 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
|
||||
|
||||
func (d *DB) UpdateMemo(ctx context.Context, update *store.UpdateMemo) error {
|
||||
set, args := []string{}, []any{}
|
||||
if v := update.ResourceName; v != nil {
|
||||
set, args = append(set, "`resource_name` = ?"), append(args, *v)
|
||||
if v := update.UID; v != nil {
|
||||
set, args = append(set, "`uid` = ?"), append(args, *v)
|
||||
}
|
||||
if v := update.CreatedTs; v != nil {
|
||||
set, args = append(set, "`created_ts` = ?"), append(args, *v)
|
||||
|
Reference in New Issue
Block a user