This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.aiterp.net/rpdata/api/models"
|
||||
)
|
||||
|
||||
type LogRepository interface {
|
||||
Find(ctx context.Context, id string) (*models.Log, error)
|
||||
List(ctx context.Context, filter models.LogFilter) ([]*models.Log, error)
|
||||
Insert(ctx context.Context, log models.Log) (*models.Log, error)
|
||||
Update(ctx context.Context, log models.Log, update models.LogUpdate) (*models.Log, error)
|
||||
Delete(ctx context.Context, log models.Log) error
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.aiterp.net/rpdata/api/models"
|
||||
)
|
||||
|
||||
type PostRepository interface {
|
||||
Find(ctx context.Context, id string) (*models.Post, error)
|
||||
List(ctx context.Context, filter models.PostFilter) ([]*models.Post, error)
|
||||
Insert(ctx context.Context, post models.Post) (*models.Post, error)
|
||||
InsertMany(ctx context.Context, posts ...*models.Post) ([]*models.Post, error)
|
||||
Update(ctx context.Context, post models.Post, update models.PostUpdate) (*models.Post, error)
|
||||
Move(ctx context.Context, post models.Post, position int) ([]*models.Post, error)
|
||||
Delete(ctx context.Context, post models.Post) error
|
||||
}
|
||||
@@ -3,4 +3,10 @@ package repositories
|
||||
import "errors"
|
||||
|
||||
// ErrNotFound should be returned instead of any database-specific not found error.
|
||||
var ErrNotFound = errors.New("Resource not found")
|
||||
var ErrNotFound = errors.New("resource not found")
|
||||
|
||||
// ErrInvalidPosition is returned when the log post is attempted moved outside of the range.
|
||||
var ErrInvalidPosition = errors.New("position is out of bounds")
|
||||
|
||||
// ErrParentMismatch is returned if the list refer to different parent objects when it shouldn't.
|
||||
var ErrParentMismatch = errors.New("parent resource is not the same for the entire list")
|
||||
|
||||
Reference in New Issue
Block a user