Storage to uuids

This commit is contained in:
breel
2020-08-07 16:15:52 -06:00
parent 953d2d1365
commit 304956da74
17 changed files with 862 additions and 186 deletions

View File

@@ -31,6 +31,20 @@ func (g Graph) ListCaseInsensitive(ctx context.Context, namespace string, from .
return g.find(ctx, namespace, filter)
}
func (g Graph) Get(ctx context.Context, namespace, id string) (entity.One, error) {
ones, err := g.find(ctx, namespace, bson.M{entity.ID: id})
if err != nil {
return entity.One{}, err
}
if len(ones) == 0 {
return entity.One{}, errors.New("not found")
}
if len(ones) > 1 {
return entity.One{}, errors.New("primary key collision detected")
}
return ones[0], nil
}
func (g Graph) List(ctx context.Context, namespace string, from ...string) ([]entity.One, error) {
filter := operator.NewFilterIn(entity.Name, from)
return g.find(ctx, namespace, filter)
@@ -68,7 +82,7 @@ func (g Graph) Insert(ctx context.Context, namespace string, one entity.One) err
return g.driver.Insert(ctx, namespace, one)
}
func (g Graph) Update(ctx context.Context, namespace string, one entity.One, modify interface{}) error {
func (g Graph) Update(ctx context.Context, namespace string, one, modify interface{}) error {
return g.driver.Update(ctx, namespace, one, modify)
}