activity.go 518 B

12345678910111213141516171819202122232425262728
  1. package sqlite
  2. import (
  3. "context"
  4. "github.com/usememos/memos/store"
  5. )
  6. func (d *DB) CreateActivity(ctx context.Context, create *store.Activity) (*store.Activity, error) {
  7. stmt := `
  8. INSERT INTO activity (
  9. creator_id,
  10. type,
  11. level,
  12. payload
  13. )
  14. VALUES (?, ?, ?, ?)
  15. RETURNING id, created_ts
  16. `
  17. if err := d.db.QueryRowContext(ctx, stmt, create.CreatorID, create.Type, create.Level, create.Payload).Scan(
  18. &create.ID,
  19. &create.CreatedTs,
  20. ); err != nil {
  21. return nil, err
  22. }
  23. return create, nil
  24. }