Storage to uuids
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user