new auth
This commit is contained in:
@@ -71,13 +71,13 @@ 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 one.ID == "" {
|
||||
return errors.New("cannot create document without id")
|
||||
}
|
||||
if ones, err := g.ListCaseInsensitive(ctx, namespace, one.Name); err != nil {
|
||||
if ones, err := g.ListCaseInsensitive(ctx, namespace, one.ID); err != nil {
|
||||
return err
|
||||
} else if len(ones) > 0 {
|
||||
return fmt.Errorf("collision on primary key when case insensitive: cannot create %q because %+v exists", one.Name, ones)
|
||||
return fmt.Errorf("collision on primary key when case insensitive: cannot create %q because %+v exists", one.ID, ones)
|
||||
}
|
||||
return g.driver.Insert(ctx, namespace, one)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user