Support primary key ID and unique key Name where api uses name
This commit is contained in:
@@ -2,6 +2,7 @@ package storage
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"local/dndex/storage/driver"
|
||||
"local/dndex/storage/entity"
|
||||
@@ -56,6 +57,9 @@ func (g Graph) gatherOnes(ctx context.Context, ch <-chan bson.Raw) ([]entity.One
|
||||
}
|
||||
|
||||
func (g Graph) Insert(ctx context.Context, namespace string, one entity.One) error {
|
||||
if one.Name == "" || one.ID == "" {
|
||||
return errors.New("cannot create document without both name and id")
|
||||
}
|
||||
if ones, err := g.ListCaseInsensitive(ctx, namespace, one.Name); err != nil {
|
||||
return err
|
||||
} else if len(ones) > 0 {
|
||||
|
||||
Reference in New Issue
Block a user