Merge branch 'main' of git.mstar.dev:mstar/linstrom
This commit is contained in:
commit
412a8be600
13 changed files with 709 additions and 252 deletions
394
storage-new/dbgen/activities.gen.go
Normal file
394
storage-new/dbgen/activities.gen.go
Normal file
|
@ -0,0 +1,394 @@
|
||||||
|
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||||
|
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||||
|
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||||
|
|
||||||
|
package dbgen
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"database/sql"
|
||||||
|
|
||||||
|
"git.mstar.dev/mstar/linstrom/storage-new/models"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"gorm.io/gorm/clause"
|
||||||
|
"gorm.io/gorm/schema"
|
||||||
|
|
||||||
|
"gorm.io/gen"
|
||||||
|
"gorm.io/gen/field"
|
||||||
|
|
||||||
|
"gorm.io/plugin/dbresolver"
|
||||||
|
)
|
||||||
|
|
||||||
|
func newActivity(db *gorm.DB, opts ...gen.DOOption) activity {
|
||||||
|
_activity := activity{}
|
||||||
|
|
||||||
|
_activity.activityDo.UseDB(db, opts...)
|
||||||
|
_activity.activityDo.UseModel(&models.Activity{})
|
||||||
|
|
||||||
|
tableName := _activity.activityDo.TableName()
|
||||||
|
_activity.ALL = field.NewAsterisk(tableName)
|
||||||
|
_activity.Id = field.NewString(tableName, "id")
|
||||||
|
_activity.Type = field.NewString(tableName, "type")
|
||||||
|
_activity.ObjectId = field.NewString(tableName, "object_id")
|
||||||
|
_activity.ObjectType = field.NewUint32(tableName, "object_type")
|
||||||
|
|
||||||
|
_activity.fillFieldMap()
|
||||||
|
|
||||||
|
return _activity
|
||||||
|
}
|
||||||
|
|
||||||
|
type activity struct {
|
||||||
|
activityDo
|
||||||
|
|
||||||
|
ALL field.Asterisk
|
||||||
|
Id field.String
|
||||||
|
Type field.String
|
||||||
|
ObjectId field.String
|
||||||
|
ObjectType field.Uint32
|
||||||
|
|
||||||
|
fieldMap map[string]field.Expr
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activity) Table(newTableName string) *activity {
|
||||||
|
a.activityDo.UseTable(newTableName)
|
||||||
|
return a.updateTableName(newTableName)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activity) As(alias string) *activity {
|
||||||
|
a.activityDo.DO = *(a.activityDo.As(alias).(*gen.DO))
|
||||||
|
return a.updateTableName(alias)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *activity) updateTableName(table string) *activity {
|
||||||
|
a.ALL = field.NewAsterisk(table)
|
||||||
|
a.Id = field.NewString(table, "id")
|
||||||
|
a.Type = field.NewString(table, "type")
|
||||||
|
a.ObjectId = field.NewString(table, "object_id")
|
||||||
|
a.ObjectType = field.NewUint32(table, "object_type")
|
||||||
|
|
||||||
|
a.fillFieldMap()
|
||||||
|
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *activity) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||||
|
_f, ok := a.fieldMap[fieldName]
|
||||||
|
if !ok || _f == nil {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
_oe, ok := _f.(field.OrderExpr)
|
||||||
|
return _oe, ok
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *activity) fillFieldMap() {
|
||||||
|
a.fieldMap = make(map[string]field.Expr, 4)
|
||||||
|
a.fieldMap["id"] = a.Id
|
||||||
|
a.fieldMap["type"] = a.Type
|
||||||
|
a.fieldMap["object_id"] = a.ObjectId
|
||||||
|
a.fieldMap["object_type"] = a.ObjectType
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activity) clone(db *gorm.DB) activity {
|
||||||
|
a.activityDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activity) replaceDB(db *gorm.DB) activity {
|
||||||
|
a.activityDo.ReplaceDB(db)
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
|
||||||
|
type activityDo struct{ gen.DO }
|
||||||
|
|
||||||
|
type IActivityDo interface {
|
||||||
|
gen.SubQuery
|
||||||
|
Debug() IActivityDo
|
||||||
|
WithContext(ctx context.Context) IActivityDo
|
||||||
|
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||||
|
ReplaceDB(db *gorm.DB)
|
||||||
|
ReadDB() IActivityDo
|
||||||
|
WriteDB() IActivityDo
|
||||||
|
As(alias string) gen.Dao
|
||||||
|
Session(config *gorm.Session) IActivityDo
|
||||||
|
Columns(cols ...field.Expr) gen.Columns
|
||||||
|
Clauses(conds ...clause.Expression) IActivityDo
|
||||||
|
Not(conds ...gen.Condition) IActivityDo
|
||||||
|
Or(conds ...gen.Condition) IActivityDo
|
||||||
|
Select(conds ...field.Expr) IActivityDo
|
||||||
|
Where(conds ...gen.Condition) IActivityDo
|
||||||
|
Order(conds ...field.Expr) IActivityDo
|
||||||
|
Distinct(cols ...field.Expr) IActivityDo
|
||||||
|
Omit(cols ...field.Expr) IActivityDo
|
||||||
|
Join(table schema.Tabler, on ...field.Expr) IActivityDo
|
||||||
|
LeftJoin(table schema.Tabler, on ...field.Expr) IActivityDo
|
||||||
|
RightJoin(table schema.Tabler, on ...field.Expr) IActivityDo
|
||||||
|
Group(cols ...field.Expr) IActivityDo
|
||||||
|
Having(conds ...gen.Condition) IActivityDo
|
||||||
|
Limit(limit int) IActivityDo
|
||||||
|
Offset(offset int) IActivityDo
|
||||||
|
Count() (count int64, err error)
|
||||||
|
Scopes(funcs ...func(gen.Dao) gen.Dao) IActivityDo
|
||||||
|
Unscoped() IActivityDo
|
||||||
|
Create(values ...*models.Activity) error
|
||||||
|
CreateInBatches(values []*models.Activity, batchSize int) error
|
||||||
|
Save(values ...*models.Activity) error
|
||||||
|
First() (*models.Activity, error)
|
||||||
|
Take() (*models.Activity, error)
|
||||||
|
Last() (*models.Activity, error)
|
||||||
|
Find() ([]*models.Activity, error)
|
||||||
|
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Activity, err error)
|
||||||
|
FindInBatches(result *[]*models.Activity, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||||
|
Pluck(column field.Expr, dest interface{}) error
|
||||||
|
Delete(...*models.Activity) (info gen.ResultInfo, err error)
|
||||||
|
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
||||||
|
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
||||||
|
Updates(value interface{}) (info gen.ResultInfo, err error)
|
||||||
|
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
||||||
|
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
||||||
|
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
|
||||||
|
UpdateFrom(q gen.SubQuery) gen.Dao
|
||||||
|
Attrs(attrs ...field.AssignExpr) IActivityDo
|
||||||
|
Assign(attrs ...field.AssignExpr) IActivityDo
|
||||||
|
Joins(fields ...field.RelationField) IActivityDo
|
||||||
|
Preload(fields ...field.RelationField) IActivityDo
|
||||||
|
FirstOrInit() (*models.Activity, error)
|
||||||
|
FirstOrCreate() (*models.Activity, error)
|
||||||
|
FindByPage(offset int, limit int) (result []*models.Activity, count int64, err error)
|
||||||
|
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
||||||
|
Rows() (*sql.Rows, error)
|
||||||
|
Row() *sql.Row
|
||||||
|
Scan(result interface{}) (err error)
|
||||||
|
Returning(value interface{}, columns ...string) IActivityDo
|
||||||
|
UnderlyingDB() *gorm.DB
|
||||||
|
schema.Tabler
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) Debug() IActivityDo {
|
||||||
|
return a.withDO(a.DO.Debug())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) WithContext(ctx context.Context) IActivityDo {
|
||||||
|
return a.withDO(a.DO.WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) ReadDB() IActivityDo {
|
||||||
|
return a.Clauses(dbresolver.Read)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) WriteDB() IActivityDo {
|
||||||
|
return a.Clauses(dbresolver.Write)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) Session(config *gorm.Session) IActivityDo {
|
||||||
|
return a.withDO(a.DO.Session(config))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) Clauses(conds ...clause.Expression) IActivityDo {
|
||||||
|
return a.withDO(a.DO.Clauses(conds...))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) Returning(value interface{}, columns ...string) IActivityDo {
|
||||||
|
return a.withDO(a.DO.Returning(value, columns...))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) Not(conds ...gen.Condition) IActivityDo {
|
||||||
|
return a.withDO(a.DO.Not(conds...))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) Or(conds ...gen.Condition) IActivityDo {
|
||||||
|
return a.withDO(a.DO.Or(conds...))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) Select(conds ...field.Expr) IActivityDo {
|
||||||
|
return a.withDO(a.DO.Select(conds...))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) Where(conds ...gen.Condition) IActivityDo {
|
||||||
|
return a.withDO(a.DO.Where(conds...))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) Order(conds ...field.Expr) IActivityDo {
|
||||||
|
return a.withDO(a.DO.Order(conds...))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) Distinct(cols ...field.Expr) IActivityDo {
|
||||||
|
return a.withDO(a.DO.Distinct(cols...))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) Omit(cols ...field.Expr) IActivityDo {
|
||||||
|
return a.withDO(a.DO.Omit(cols...))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) Join(table schema.Tabler, on ...field.Expr) IActivityDo {
|
||||||
|
return a.withDO(a.DO.Join(table, on...))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) LeftJoin(table schema.Tabler, on ...field.Expr) IActivityDo {
|
||||||
|
return a.withDO(a.DO.LeftJoin(table, on...))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) RightJoin(table schema.Tabler, on ...field.Expr) IActivityDo {
|
||||||
|
return a.withDO(a.DO.RightJoin(table, on...))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) Group(cols ...field.Expr) IActivityDo {
|
||||||
|
return a.withDO(a.DO.Group(cols...))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) Having(conds ...gen.Condition) IActivityDo {
|
||||||
|
return a.withDO(a.DO.Having(conds...))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) Limit(limit int) IActivityDo {
|
||||||
|
return a.withDO(a.DO.Limit(limit))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) Offset(offset int) IActivityDo {
|
||||||
|
return a.withDO(a.DO.Offset(offset))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IActivityDo {
|
||||||
|
return a.withDO(a.DO.Scopes(funcs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) Unscoped() IActivityDo {
|
||||||
|
return a.withDO(a.DO.Unscoped())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) Create(values ...*models.Activity) error {
|
||||||
|
if len(values) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return a.DO.Create(values)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) CreateInBatches(values []*models.Activity, batchSize int) error {
|
||||||
|
return a.DO.CreateInBatches(values, batchSize)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save : !!! underlying implementation is different with GORM
|
||||||
|
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||||
|
func (a activityDo) Save(values ...*models.Activity) error {
|
||||||
|
if len(values) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return a.DO.Save(values)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) First() (*models.Activity, error) {
|
||||||
|
if result, err := a.DO.First(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else {
|
||||||
|
return result.(*models.Activity), nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) Take() (*models.Activity, error) {
|
||||||
|
if result, err := a.DO.Take(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else {
|
||||||
|
return result.(*models.Activity), nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) Last() (*models.Activity, error) {
|
||||||
|
if result, err := a.DO.Last(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else {
|
||||||
|
return result.(*models.Activity), nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) Find() ([]*models.Activity, error) {
|
||||||
|
result, err := a.DO.Find()
|
||||||
|
return result.([]*models.Activity), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Activity, err error) {
|
||||||
|
buf := make([]*models.Activity, 0, batchSize)
|
||||||
|
err = a.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||||
|
defer func() { results = append(results, buf...) }()
|
||||||
|
return fc(tx, batch)
|
||||||
|
})
|
||||||
|
return results, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) FindInBatches(result *[]*models.Activity, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||||
|
return a.DO.FindInBatches(result, batchSize, fc)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) Attrs(attrs ...field.AssignExpr) IActivityDo {
|
||||||
|
return a.withDO(a.DO.Attrs(attrs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) Assign(attrs ...field.AssignExpr) IActivityDo {
|
||||||
|
return a.withDO(a.DO.Assign(attrs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) Joins(fields ...field.RelationField) IActivityDo {
|
||||||
|
for _, _f := range fields {
|
||||||
|
a = *a.withDO(a.DO.Joins(_f))
|
||||||
|
}
|
||||||
|
return &a
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) Preload(fields ...field.RelationField) IActivityDo {
|
||||||
|
for _, _f := range fields {
|
||||||
|
a = *a.withDO(a.DO.Preload(_f))
|
||||||
|
}
|
||||||
|
return &a
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) FirstOrInit() (*models.Activity, error) {
|
||||||
|
if result, err := a.DO.FirstOrInit(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else {
|
||||||
|
return result.(*models.Activity), nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) FirstOrCreate() (*models.Activity, error) {
|
||||||
|
if result, err := a.DO.FirstOrCreate(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else {
|
||||||
|
return result.(*models.Activity), nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) FindByPage(offset int, limit int) (result []*models.Activity, count int64, err error) {
|
||||||
|
result, err = a.Offset(offset).Limit(limit).Find()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||||
|
count = int64(size + offset)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
count, err = a.Offset(-1).Limit(-1).Count()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||||
|
count, err = a.Count()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = a.Offset(offset).Limit(limit).Scan(result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) Scan(result interface{}) (err error) {
|
||||||
|
return a.DO.Scan(result)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a activityDo) Delete(models ...*models.Activity) (result gen.ResultInfo, err error) {
|
||||||
|
return a.DO.Delete(models)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *activityDo) withDO(do gen.Dao) *activityDo {
|
||||||
|
a.DO = *do.(*gen.DO)
|
||||||
|
return a
|
||||||
|
}
|
|
@ -23,7 +23,7 @@ func newActivitystreamsActivity(db *gorm.DB, opts ...gen.DOOption) activitystrea
|
||||||
_activitystreamsActivity := activitystreamsActivity{}
|
_activitystreamsActivity := activitystreamsActivity{}
|
||||||
|
|
||||||
_activitystreamsActivity.activitystreamsActivityDo.UseDB(db, opts...)
|
_activitystreamsActivity.activitystreamsActivityDo.UseDB(db, opts...)
|
||||||
_activitystreamsActivity.activitystreamsActivityDo.UseModel(&models.ActivitystreamsActivity{})
|
_activitystreamsActivity.activitystreamsActivityDo.UseModel(&models.Activity{})
|
||||||
|
|
||||||
tableName := _activitystreamsActivity.activitystreamsActivityDo.TableName()
|
tableName := _activitystreamsActivity.activitystreamsActivityDo.TableName()
|
||||||
_activitystreamsActivity.ALL = field.NewAsterisk(tableName)
|
_activitystreamsActivity.ALL = field.NewAsterisk(tableName)
|
||||||
|
@ -129,17 +129,17 @@ type IActivitystreamsActivityDo interface {
|
||||||
Count() (count int64, err error)
|
Count() (count int64, err error)
|
||||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IActivitystreamsActivityDo
|
Scopes(funcs ...func(gen.Dao) gen.Dao) IActivitystreamsActivityDo
|
||||||
Unscoped() IActivitystreamsActivityDo
|
Unscoped() IActivitystreamsActivityDo
|
||||||
Create(values ...*models.ActivitystreamsActivity) error
|
Create(values ...*models.Activity) error
|
||||||
CreateInBatches(values []*models.ActivitystreamsActivity, batchSize int) error
|
CreateInBatches(values []*models.Activity, batchSize int) error
|
||||||
Save(values ...*models.ActivitystreamsActivity) error
|
Save(values ...*models.Activity) error
|
||||||
First() (*models.ActivitystreamsActivity, error)
|
First() (*models.Activity, error)
|
||||||
Take() (*models.ActivitystreamsActivity, error)
|
Take() (*models.Activity, error)
|
||||||
Last() (*models.ActivitystreamsActivity, error)
|
Last() (*models.Activity, error)
|
||||||
Find() ([]*models.ActivitystreamsActivity, error)
|
Find() ([]*models.Activity, error)
|
||||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.ActivitystreamsActivity, err error)
|
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Activity, err error)
|
||||||
FindInBatches(result *[]*models.ActivitystreamsActivity, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
FindInBatches(result *[]*models.Activity, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||||
Pluck(column field.Expr, dest interface{}) error
|
Pluck(column field.Expr, dest interface{}) error
|
||||||
Delete(...*models.ActivitystreamsActivity) (info gen.ResultInfo, err error)
|
Delete(...*models.Activity) (info gen.ResultInfo, err error)
|
||||||
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
||||||
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
||||||
Updates(value interface{}) (info gen.ResultInfo, err error)
|
Updates(value interface{}) (info gen.ResultInfo, err error)
|
||||||
|
@ -151,9 +151,9 @@ type IActivitystreamsActivityDo interface {
|
||||||
Assign(attrs ...field.AssignExpr) IActivitystreamsActivityDo
|
Assign(attrs ...field.AssignExpr) IActivitystreamsActivityDo
|
||||||
Joins(fields ...field.RelationField) IActivitystreamsActivityDo
|
Joins(fields ...field.RelationField) IActivitystreamsActivityDo
|
||||||
Preload(fields ...field.RelationField) IActivitystreamsActivityDo
|
Preload(fields ...field.RelationField) IActivitystreamsActivityDo
|
||||||
FirstOrInit() (*models.ActivitystreamsActivity, error)
|
FirstOrInit() (*models.Activity, error)
|
||||||
FirstOrCreate() (*models.ActivitystreamsActivity, error)
|
FirstOrCreate() (*models.Activity, error)
|
||||||
FindByPage(offset int, limit int) (result []*models.ActivitystreamsActivity, count int64, err error)
|
FindByPage(offset int, limit int) (result []*models.Activity, count int64, err error)
|
||||||
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
||||||
Rows() (*sql.Rows, error)
|
Rows() (*sql.Rows, error)
|
||||||
Row() *sql.Row
|
Row() *sql.Row
|
||||||
|
@ -255,57 +255,57 @@ func (a activitystreamsActivityDo) Unscoped() IActivitystreamsActivityDo {
|
||||||
return a.withDO(a.DO.Unscoped())
|
return a.withDO(a.DO.Unscoped())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a activitystreamsActivityDo) Create(values ...*models.ActivitystreamsActivity) error {
|
func (a activitystreamsActivityDo) Create(values ...*models.Activity) error {
|
||||||
if len(values) == 0 {
|
if len(values) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return a.DO.Create(values)
|
return a.DO.Create(values)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a activitystreamsActivityDo) CreateInBatches(values []*models.ActivitystreamsActivity, batchSize int) error {
|
func (a activitystreamsActivityDo) CreateInBatches(values []*models.Activity, batchSize int) error {
|
||||||
return a.DO.CreateInBatches(values, batchSize)
|
return a.DO.CreateInBatches(values, batchSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save : !!! underlying implementation is different with GORM
|
// Save : !!! underlying implementation is different with GORM
|
||||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||||
func (a activitystreamsActivityDo) Save(values ...*models.ActivitystreamsActivity) error {
|
func (a activitystreamsActivityDo) Save(values ...*models.Activity) error {
|
||||||
if len(values) == 0 {
|
if len(values) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return a.DO.Save(values)
|
return a.DO.Save(values)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a activitystreamsActivityDo) First() (*models.ActivitystreamsActivity, error) {
|
func (a activitystreamsActivityDo) First() (*models.Activity, error) {
|
||||||
if result, err := a.DO.First(); err != nil {
|
if result, err := a.DO.First(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
} else {
|
||||||
return result.(*models.ActivitystreamsActivity), nil
|
return result.(*models.Activity), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a activitystreamsActivityDo) Take() (*models.ActivitystreamsActivity, error) {
|
func (a activitystreamsActivityDo) Take() (*models.Activity, error) {
|
||||||
if result, err := a.DO.Take(); err != nil {
|
if result, err := a.DO.Take(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
} else {
|
||||||
return result.(*models.ActivitystreamsActivity), nil
|
return result.(*models.Activity), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a activitystreamsActivityDo) Last() (*models.ActivitystreamsActivity, error) {
|
func (a activitystreamsActivityDo) Last() (*models.Activity, error) {
|
||||||
if result, err := a.DO.Last(); err != nil {
|
if result, err := a.DO.Last(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
} else {
|
||||||
return result.(*models.ActivitystreamsActivity), nil
|
return result.(*models.Activity), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a activitystreamsActivityDo) Find() ([]*models.ActivitystreamsActivity, error) {
|
func (a activitystreamsActivityDo) Find() ([]*models.Activity, error) {
|
||||||
result, err := a.DO.Find()
|
result, err := a.DO.Find()
|
||||||
return result.([]*models.ActivitystreamsActivity), err
|
return result.([]*models.Activity), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a activitystreamsActivityDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.ActivitystreamsActivity, err error) {
|
func (a activitystreamsActivityDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Activity, err error) {
|
||||||
buf := make([]*models.ActivitystreamsActivity, 0, batchSize)
|
buf := make([]*models.Activity, 0, batchSize)
|
||||||
err = a.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
err = a.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||||
defer func() { results = append(results, buf...) }()
|
defer func() { results = append(results, buf...) }()
|
||||||
return fc(tx, batch)
|
return fc(tx, batch)
|
||||||
|
@ -313,7 +313,7 @@ func (a activitystreamsActivityDo) FindInBatch(batchSize int, fc func(tx gen.Dao
|
||||||
return results, err
|
return results, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a activitystreamsActivityDo) FindInBatches(result *[]*models.ActivitystreamsActivity, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
func (a activitystreamsActivityDo) FindInBatches(result *[]*models.Activity, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||||
return a.DO.FindInBatches(result, batchSize, fc)
|
return a.DO.FindInBatches(result, batchSize, fc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,23 +339,23 @@ func (a activitystreamsActivityDo) Preload(fields ...field.RelationField) IActiv
|
||||||
return &a
|
return &a
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a activitystreamsActivityDo) FirstOrInit() (*models.ActivitystreamsActivity, error) {
|
func (a activitystreamsActivityDo) FirstOrInit() (*models.Activity, error) {
|
||||||
if result, err := a.DO.FirstOrInit(); err != nil {
|
if result, err := a.DO.FirstOrInit(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
} else {
|
||||||
return result.(*models.ActivitystreamsActivity), nil
|
return result.(*models.Activity), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a activitystreamsActivityDo) FirstOrCreate() (*models.ActivitystreamsActivity, error) {
|
func (a activitystreamsActivityDo) FirstOrCreate() (*models.Activity, error) {
|
||||||
if result, err := a.DO.FirstOrCreate(); err != nil {
|
if result, err := a.DO.FirstOrCreate(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
} else {
|
||||||
return result.(*models.ActivitystreamsActivity), nil
|
return result.(*models.Activity), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a activitystreamsActivityDo) FindByPage(offset int, limit int) (result []*models.ActivitystreamsActivity, count int64, err error) {
|
func (a activitystreamsActivityDo) FindByPage(offset int, limit int) (result []*models.Activity, count int64, err error) {
|
||||||
result, err = a.Offset(offset).Limit(limit).Find()
|
result, err = a.Offset(offset).Limit(limit).Find()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
@ -384,7 +384,7 @@ func (a activitystreamsActivityDo) Scan(result interface{}) (err error) {
|
||||||
return a.DO.Scan(result)
|
return a.DO.Scan(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a activitystreamsActivityDo) Delete(models ...*models.ActivitystreamsActivity) (result gen.ResultInfo, err error) {
|
func (a activitystreamsActivityDo) Delete(models ...*models.Activity) (result gen.ResultInfo, err error) {
|
||||||
return a.DO.Delete(models)
|
return a.DO.Delete(models)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ func newCollection(db *gorm.DB, opts ...gen.DOOption) collection {
|
||||||
_collection.ALL = field.NewAsterisk(tableName)
|
_collection.ALL = field.NewAsterisk(tableName)
|
||||||
_collection.Id = field.NewString(tableName, "id")
|
_collection.Id = field.NewString(tableName, "id")
|
||||||
_collection.TargetId = field.NewString(tableName, "target_id")
|
_collection.TargetId = field.NewString(tableName, "target_id")
|
||||||
_collection.TargetType = field.NewUint32(tableName, "target_type")
|
_collection.TargetType = field.NewString(tableName, "target_type")
|
||||||
|
|
||||||
_collection.fillFieldMap()
|
_collection.fillFieldMap()
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ type collection struct {
|
||||||
ALL field.Asterisk
|
ALL field.Asterisk
|
||||||
Id field.String
|
Id field.String
|
||||||
TargetId field.String
|
TargetId field.String
|
||||||
TargetType field.Uint32
|
TargetType field.String
|
||||||
|
|
||||||
fieldMap map[string]field.Expr
|
fieldMap map[string]field.Expr
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ func (c *collection) updateTableName(table string) *collection {
|
||||||
c.ALL = field.NewAsterisk(table)
|
c.ALL = field.NewAsterisk(table)
|
||||||
c.Id = field.NewString(table, "id")
|
c.Id = field.NewString(table, "id")
|
||||||
c.TargetId = field.NewString(table, "target_id")
|
c.TargetId = field.NewString(table, "target_id")
|
||||||
c.TargetType = field.NewUint32(table, "target_type")
|
c.TargetType = field.NewString(table, "target_type")
|
||||||
|
|
||||||
c.fillFieldMap()
|
c.fillFieldMap()
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ import (
|
||||||
var (
|
var (
|
||||||
Q = new(Query)
|
Q = new(Query)
|
||||||
AccessToken *accessToken
|
AccessToken *accessToken
|
||||||
ActivitystreamsActivity *activitystreamsActivity
|
Activity *activity
|
||||||
Collection *collection
|
Collection *collection
|
||||||
Emote *emote
|
Emote *emote
|
||||||
Feed *feed
|
Feed *feed
|
||||||
|
@ -51,7 +51,7 @@ var (
|
||||||
func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
|
func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
|
||||||
*Q = *Use(db, opts...)
|
*Q = *Use(db, opts...)
|
||||||
AccessToken = &Q.AccessToken
|
AccessToken = &Q.AccessToken
|
||||||
ActivitystreamsActivity = &Q.ActivitystreamsActivity
|
Activity = &Q.Activity
|
||||||
Collection = &Q.Collection
|
Collection = &Q.Collection
|
||||||
Emote = &Q.Emote
|
Emote = &Q.Emote
|
||||||
Feed = &Q.Feed
|
Feed = &Q.Feed
|
||||||
|
@ -85,7 +85,7 @@ func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
|
||||||
return &Query{
|
return &Query{
|
||||||
db: db,
|
db: db,
|
||||||
AccessToken: newAccessToken(db, opts...),
|
AccessToken: newAccessToken(db, opts...),
|
||||||
ActivitystreamsActivity: newActivitystreamsActivity(db, opts...),
|
Activity: newActivity(db, opts...),
|
||||||
Collection: newCollection(db, opts...),
|
Collection: newCollection(db, opts...),
|
||||||
Emote: newEmote(db, opts...),
|
Emote: newEmote(db, opts...),
|
||||||
Feed: newFeed(db, opts...),
|
Feed: newFeed(db, opts...),
|
||||||
|
@ -120,7 +120,7 @@ type Query struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
|
|
||||||
AccessToken accessToken
|
AccessToken accessToken
|
||||||
ActivitystreamsActivity activitystreamsActivity
|
Activity activity
|
||||||
Collection collection
|
Collection collection
|
||||||
Emote emote
|
Emote emote
|
||||||
Feed feed
|
Feed feed
|
||||||
|
@ -156,7 +156,7 @@ func (q *Query) clone(db *gorm.DB) *Query {
|
||||||
return &Query{
|
return &Query{
|
||||||
db: db,
|
db: db,
|
||||||
AccessToken: q.AccessToken.clone(db),
|
AccessToken: q.AccessToken.clone(db),
|
||||||
ActivitystreamsActivity: q.ActivitystreamsActivity.clone(db),
|
Activity: q.Activity.clone(db),
|
||||||
Collection: q.Collection.clone(db),
|
Collection: q.Collection.clone(db),
|
||||||
Emote: q.Emote.clone(db),
|
Emote: q.Emote.clone(db),
|
||||||
Feed: q.Feed.clone(db),
|
Feed: q.Feed.clone(db),
|
||||||
|
@ -199,7 +199,7 @@ func (q *Query) ReplaceDB(db *gorm.DB) *Query {
|
||||||
return &Query{
|
return &Query{
|
||||||
db: db,
|
db: db,
|
||||||
AccessToken: q.AccessToken.replaceDB(db),
|
AccessToken: q.AccessToken.replaceDB(db),
|
||||||
ActivitystreamsActivity: q.ActivitystreamsActivity.replaceDB(db),
|
Activity: q.Activity.replaceDB(db),
|
||||||
Collection: q.Collection.replaceDB(db),
|
Collection: q.Collection.replaceDB(db),
|
||||||
Emote: q.Emote.replaceDB(db),
|
Emote: q.Emote.replaceDB(db),
|
||||||
Feed: q.Feed.replaceDB(db),
|
Feed: q.Feed.replaceDB(db),
|
||||||
|
@ -232,7 +232,7 @@ func (q *Query) ReplaceDB(db *gorm.DB) *Query {
|
||||||
|
|
||||||
type queryCtx struct {
|
type queryCtx struct {
|
||||||
AccessToken IAccessTokenDo
|
AccessToken IAccessTokenDo
|
||||||
ActivitystreamsActivity IActivitystreamsActivityDo
|
Activity IActivityDo
|
||||||
Collection ICollectionDo
|
Collection ICollectionDo
|
||||||
Emote IEmoteDo
|
Emote IEmoteDo
|
||||||
Feed IFeedDo
|
Feed IFeedDo
|
||||||
|
@ -265,7 +265,7 @@ type queryCtx struct {
|
||||||
func (q *Query) WithContext(ctx context.Context) *queryCtx {
|
func (q *Query) WithContext(ctx context.Context) *queryCtx {
|
||||||
return &queryCtx{
|
return &queryCtx{
|
||||||
AccessToken: q.AccessToken.WithContext(ctx),
|
AccessToken: q.AccessToken.WithContext(ctx),
|
||||||
ActivitystreamsActivity: q.ActivitystreamsActivity.WithContext(ctx),
|
Activity: q.Activity.WithContext(ctx),
|
||||||
Collection: q.Collection.WithContext(ctx),
|
Collection: q.Collection.WithContext(ctx),
|
||||||
Emote: q.Emote.WithContext(ctx),
|
Emote: q.Emote.WithContext(ctx),
|
||||||
Feed: q.Feed.WithContext(ctx),
|
Feed: q.Feed.WithContext(ctx),
|
||||||
|
|
|
@ -37,6 +37,9 @@ func Migrate(db *gorm.DB) error {
|
||||||
if err := createActitiystreamsActivityType(db); err != nil {
|
if err := createActitiystreamsActivityType(db); err != nil {
|
||||||
return other.Error("storage", "Failed to create Activitystreams Activity type", err)
|
return other.Error("storage", "Failed to create Activitystreams Activity type", err)
|
||||||
}
|
}
|
||||||
|
if err := createCollectionTarget(db); err != nil {
|
||||||
|
return other.Error("storage", "Failed t ocreate collections target type", err)
|
||||||
|
}
|
||||||
if err := migrateTypes(db); err != nil {
|
if err := migrateTypes(db); err != nil {
|
||||||
return other.Error("storage", "Failed to automigrate data structs", err)
|
return other.Error("storage", "Failed to automigrate data structs", err)
|
||||||
}
|
}
|
||||||
|
@ -126,6 +129,17 @@ func createActitiystreamsActivityTargetType(db *gorm.DB) error {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func createCollectionTarget(db *gorm.DB) error {
|
||||||
|
return migrateEnum(
|
||||||
|
db,
|
||||||
|
"collection_target_type",
|
||||||
|
sliceutils.Map(
|
||||||
|
models.AllCollectionTargetTypes,
|
||||||
|
func(t models.CollectionTargetType) string { return string(t) },
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// Helper function for ensuring the existence of an enum with the given values
|
// Helper function for ensuring the existence of an enum with the given values
|
||||||
func migrateEnum(db *gorm.DB, name string, values []string) error {
|
func migrateEnum(db *gorm.DB, name string, values []string) error {
|
||||||
if err := db.Exec("DROP TYPE IF EXISTS " + name + " CASCADE;").Error; err != nil {
|
if err := db.Exec("DROP TYPE IF EXISTS " + name + " CASCADE;").Error; err != nil {
|
||||||
|
|
|
@ -2,8 +2,8 @@ package models
|
||||||
|
|
||||||
// A list of all models stored in the database
|
// A list of all models stored in the database
|
||||||
var AllTypes = []any{
|
var AllTypes = []any{
|
||||||
|
&Activity{},
|
||||||
&Collection{},
|
&Collection{},
|
||||||
&ActivitystreamsActivity{},
|
|
||||||
&Emote{},
|
&Emote{},
|
||||||
&Feed{},
|
&Feed{},
|
||||||
&MediaMetadata{},
|
&MediaMetadata{},
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
type ActivitystreamsActivity struct {
|
type Activity struct {
|
||||||
Id string `gorm:"primarykey"`
|
Id string `gorm:"primarykey"`
|
||||||
Type string `gorm:"type:activitystreams_activity_type"`
|
Type string `gorm:"type:activitystreams_activity_type"`
|
||||||
ObjectId string
|
ObjectId string
|
|
@ -3,5 +3,5 @@ package models
|
||||||
type Collection struct {
|
type Collection struct {
|
||||||
Id string `gorm:"primarykey"`
|
Id string `gorm:"primarykey"`
|
||||||
TargetId string
|
TargetId string
|
||||||
TargetType uint32
|
TargetType string `orm:"type:collection_target_type"`
|
||||||
}
|
}
|
28
storage-new/models/CollectionTargetType.go
Normal file
28
storage-new/models/CollectionTargetType.go
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
package models
|
||||||
|
|
||||||
|
import "database/sql/driver"
|
||||||
|
|
||||||
|
type CollectionTargetType string
|
||||||
|
|
||||||
|
const (
|
||||||
|
CollectionTargetUnknown = CollectionTargetType("unknown")
|
||||||
|
CollectionTargetPinnedNotes = CollectionTargetType("pinned")
|
||||||
|
CollectionTargetReactions = CollectionTargetType("reactions")
|
||||||
|
CollectionTargetBoostsAndQuotes = CollectionTargetType("boosts")
|
||||||
|
)
|
||||||
|
|
||||||
|
var AllCollectionTargetTypes = []CollectionTargetType{
|
||||||
|
CollectionTargetUnknown,
|
||||||
|
CollectionTargetPinnedNotes,
|
||||||
|
CollectionTargetReactions,
|
||||||
|
CollectionTargetBoostsAndQuotes,
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *CollectionTargetType) Value() (driver.Value, error) {
|
||||||
|
return n, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ct *CollectionTargetType) Scan(value any) error {
|
||||||
|
*ct = CollectionTargetType(value.(uint32))
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"github.com/rs/zerolog/hlog"
|
"github.com/rs/zerolog/hlog"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
|
||||||
|
"git.mstar.dev/mstar/linstrom/shared"
|
||||||
"git.mstar.dev/mstar/linstrom/storage-new"
|
"git.mstar.dev/mstar/linstrom/storage-new"
|
||||||
"git.mstar.dev/mstar/linstrom/storage-new/dbgen"
|
"git.mstar.dev/mstar/linstrom/storage-new/dbgen"
|
||||||
"git.mstar.dev/mstar/linstrom/storage-new/models"
|
"git.mstar.dev/mstar/linstrom/storage-new/models"
|
||||||
|
@ -64,7 +65,7 @@ func postAs(w http.ResponseWriter, r *http.Request) {
|
||||||
AccessLevel: models.NOTE_TARGET_PUBLIC,
|
AccessLevel: models.NOTE_TARGET_PUBLIC,
|
||||||
OriginId: 1,
|
OriginId: 1,
|
||||||
}
|
}
|
||||||
n.Select(
|
err = n.Select(
|
||||||
n.CreatorId,
|
n.CreatorId,
|
||||||
n.RawContent,
|
n.RawContent,
|
||||||
n.Remote,
|
n.Remote,
|
||||||
|
@ -74,6 +75,26 @@ func postAs(w http.ResponseWriter, r *http.Request) {
|
||||||
n.AccessLevel,
|
n.AccessLevel,
|
||||||
n.OriginId,
|
n.OriginId,
|
||||||
).Create(¬e)
|
).Create(¬e)
|
||||||
|
if err != nil {
|
||||||
|
log.Error().
|
||||||
|
Err(err).
|
||||||
|
Str("username", data.Username).
|
||||||
|
Str("content", data.Content).
|
||||||
|
Msg("Failed to create message")
|
||||||
|
webutils.ProblemDetailsStatusOnly(w, http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
activity := models.Activity{
|
||||||
|
Id: shared.NewId(),
|
||||||
|
Type: string(models.ActivityCreate),
|
||||||
|
ObjectId: note.ID,
|
||||||
|
ObjectType: uint32(models.ActivitystreamsActivityTargetNote),
|
||||||
|
}
|
||||||
|
a := dbgen.Activity
|
||||||
|
err = a.Create(&activity)
|
||||||
|
if err != nil {
|
||||||
|
log.Error().Err(err).Msg("Failed to create activity for new note")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func notesFrom(w http.ResponseWriter, r *http.Request) {
|
func notesFrom(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
|
@ -58,9 +58,9 @@ func activityCreate(w http.ResponseWriter, r *http.Request) {
|
||||||
// getting the final result
|
// getting the final result
|
||||||
func createFromStorage(ctx context.Context, id string) (*activityCreateOut, error) {
|
func createFromStorage(ctx context.Context, id string) (*activityCreateOut, error) {
|
||||||
// log := log.Ctx(ctx)
|
// log := log.Ctx(ctx)
|
||||||
asa := dbgen.ActivitystreamsActivity
|
a := dbgen.Activity
|
||||||
activity, err := asa.Where(asa.Type.Eq(string(models.ActivityCreate))).
|
activity, err := a.Where(a.Type.Eq(string(models.ActivityCreate))).
|
||||||
Where(asa.Id.Eq(id)).
|
Where(a.Id.Eq(id)).
|
||||||
First()
|
First()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in a new issue