Update storage to new object format
This commit is contained in:
@@ -2,6 +2,8 @@ package storage
|
||||
|
||||
import (
|
||||
"context"
|
||||
"local/whodunit/storage/entity"
|
||||
"local/whodunit/storage/operator"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
)
|
||||
@@ -17,15 +19,15 @@ func NewGraph() Graph {
|
||||
}
|
||||
}
|
||||
|
||||
func (g Graph) List(ctx context.Context, from ...string) ([]One, error) {
|
||||
filter := newFilterIn("_id", from)
|
||||
func (g Graph) List(ctx context.Context, from ...string) ([]entity.One, error) {
|
||||
filter := operator.NewFilterIn("_id", from)
|
||||
ch, err := g.mongo.Find(ctx, filter)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var ones []One
|
||||
var ones []entity.One
|
||||
for one := range ch {
|
||||
var o One
|
||||
var o entity.One
|
||||
if err := bson.Unmarshal(one, &o); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -34,10 +36,10 @@ func (g Graph) List(ctx context.Context, from ...string) ([]One, error) {
|
||||
return ones, nil
|
||||
}
|
||||
|
||||
func (g Graph) Insert(ctx context.Context, one One) error {
|
||||
func (g Graph) Insert(ctx context.Context, one entity.One) error {
|
||||
return g.mongo.Insert(ctx, one)
|
||||
}
|
||||
|
||||
func (g Graph) Update(ctx context.Context, one One, modify interface{}) error {
|
||||
func (g Graph) Update(ctx context.Context, one entity.One, modify interface{}) error {
|
||||
return g.mongo.Update(ctx, one, modify)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user