mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: clean binary entries
This commit is contained in:
@ -26,17 +26,6 @@ func (d *DB) CreateActivity(ctx context.Context, create *store.Activity) (*store
|
||||
PlaceholderFormat(squirrel.Dollar)
|
||||
|
||||
values := []any{create.CreatorID, create.Type.String(), create.Level.String(), payloadString}
|
||||
|
||||
if create.ID != 0 {
|
||||
qb = qb.Columns("id")
|
||||
values = append(values, create.ID)
|
||||
}
|
||||
|
||||
if create.CreatedTs != 0 {
|
||||
qb = qb.Columns("created_ts")
|
||||
values = append(values, create.CreatedTs)
|
||||
}
|
||||
|
||||
qb = qb.Values(values...).Suffix("RETURNING id")
|
||||
|
||||
stmt, args, err := qb.ToSql()
|
||||
|
@ -25,11 +25,6 @@ func (d *DB) CreateIdentityProvider(ctx context.Context, create *store.IdentityP
|
||||
qb := squirrel.Insert("idp").Columns("name", "type", "identifier_filter", "config")
|
||||
values := []any{create.Name, create.Type, create.IdentifierFilter, string(configBytes)}
|
||||
|
||||
if create.ID != 0 {
|
||||
qb = qb.Columns("id")
|
||||
values = append(values, create.ID)
|
||||
}
|
||||
|
||||
qb = qb.Values(values...).PlaceholderFormat(squirrel.Dollar)
|
||||
qb = qb.Suffix("RETURNING id")
|
||||
|
||||
|
@ -21,27 +21,6 @@ func (d *DB) CreateMemo(ctx context.Context, create *store.Memo) (*store.Memo, e
|
||||
// Add initial values for the columns
|
||||
values := []any{create.CreatorID, create.Content, create.Visibility}
|
||||
|
||||
// Conditionally add other fields and values
|
||||
if create.ID != 0 {
|
||||
builder = builder.Columns("id")
|
||||
values = append(values, create.ID)
|
||||
}
|
||||
|
||||
if create.CreatedTs != 0 {
|
||||
builder = builder.Columns("created_ts")
|
||||
values = append(values, create.CreatedTs)
|
||||
}
|
||||
|
||||
if create.UpdatedTs != 0 {
|
||||
builder = builder.Columns("updated_ts")
|
||||
values = append(values, create.UpdatedTs)
|
||||
}
|
||||
|
||||
if create.RowStatus != "" {
|
||||
builder = builder.Columns("row_status")
|
||||
values = append(values, create.RowStatus)
|
||||
}
|
||||
|
||||
// Add all the values at once
|
||||
builder = builder.Values(values...)
|
||||
|
||||
|
@ -16,26 +16,6 @@ func (d *DB) CreateResource(ctx context.Context, create *store.Resource) (*store
|
||||
qb := squirrel.Insert("resource").Columns("filename", "blob", "external_link", "type", "size", "creator_id", "internal_path")
|
||||
values := []any{create.Filename, create.Blob, create.ExternalLink, create.Type, create.Size, create.CreatorID, create.InternalPath}
|
||||
|
||||
if create.ID != 0 {
|
||||
qb = qb.Columns("id")
|
||||
values = append(values, create.ID)
|
||||
}
|
||||
|
||||
if create.CreatedTs != 0 {
|
||||
qb = qb.Columns("created_ts")
|
||||
values = append(values, create.CreatedTs)
|
||||
}
|
||||
|
||||
if create.UpdatedTs != 0 {
|
||||
qb = qb.Columns("updated_ts")
|
||||
values = append(values, create.UpdatedTs)
|
||||
}
|
||||
|
||||
if create.MemoID != nil {
|
||||
qb = qb.Columns("memo_id")
|
||||
values = append(values, *create.MemoID)
|
||||
}
|
||||
|
||||
qb = qb.Values(values...).Suffix("RETURNING id")
|
||||
query, args, err := qb.PlaceholderFormat(squirrel.Dollar).ToSql()
|
||||
if err != nil {
|
||||
|
@ -12,11 +12,6 @@ func (d *DB) CreateStorage(ctx context.Context, create *store.Storage) (*store.S
|
||||
qb := squirrel.Insert("storage").Columns("name", "type", "config")
|
||||
values := []any{create.Name, create.Type, create.Config}
|
||||
|
||||
if create.ID != 0 {
|
||||
qb = qb.Columns("id")
|
||||
values = append(values, create.ID)
|
||||
}
|
||||
|
||||
qb = qb.Values(values...).Suffix("RETURNING id")
|
||||
query, args, err := qb.PlaceholderFormat(squirrel.Dollar).ToSql()
|
||||
if err != nil {
|
||||
|
@ -18,28 +18,7 @@ func (d *DB) CreateUser(ctx context.Context, create *store.User) (*store.User, e
|
||||
|
||||
values := []any{create.Username, create.Role, create.Email, create.Nickname, create.PasswordHash, create.AvatarURL}
|
||||
|
||||
if create.RowStatus != "" {
|
||||
builder = builder.Columns("row_status")
|
||||
values = append(values, create.RowStatus)
|
||||
}
|
||||
|
||||
if create.CreatedTs != 0 {
|
||||
builder = builder.Columns("created_ts")
|
||||
values = append(values, create.CreatedTs)
|
||||
}
|
||||
|
||||
if create.UpdatedTs != 0 {
|
||||
builder = builder.Columns("updated_ts")
|
||||
values = append(values, create.UpdatedTs)
|
||||
}
|
||||
|
||||
if create.ID != 0 {
|
||||
builder = builder.Columns("id")
|
||||
values = append(values, create.ID)
|
||||
}
|
||||
|
||||
builder = builder.Values(values...)
|
||||
|
||||
builder = builder.Suffix("RETURNING id")
|
||||
|
||||
// Prepare the final query
|
||||
|
@ -13,11 +13,6 @@ func (d *DB) CreateWebhook(ctx context.Context, create *storepb.Webhook) (*store
|
||||
qb := squirrel.Insert("webhook").Columns("name", "url", "creator_id")
|
||||
values := []any{create.Name, create.Url, create.CreatorId}
|
||||
|
||||
if create.Id != 0 {
|
||||
qb = qb.Columns("id")
|
||||
values = append(values, create.Id)
|
||||
}
|
||||
|
||||
qb = qb.Values(values...).Suffix("RETURNING id")
|
||||
query, args, err := qb.PlaceholderFormat(squirrel.Dollar).ToSql()
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user