Skip to content

Commit

Permalink
move lock
Browse files Browse the repository at this point in the history
  • Loading branch information
jairad26 committed Dec 18, 2024
1 parent 3e62721 commit 2e92a55
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ func valueToValType(v any) *api.Value {
}

func Create[T any](ctx context.Context, n *Namespace, object *T) (uint64, *T, error){
n.db.mutex.Lock()
defer n.db.mutex.Unlock()
uids, err := n.db.z.nextUIDs(&pb.Num{Val: uint64(1), Type: pb.Num_UID})
if err != nil {
return 0, object, err
Expand Down Expand Up @@ -152,9 +154,6 @@ func Create[T any](ctx context.Context, n *Namespace, object *T) (uint64, *T, er
}
ctx = x.AttachNamespace(ctx, n.ID())

n.db.mutex.Lock()
defer n.db.mutex.Unlock()

err = n.alterSchemaWithParsed(ctx, sch)
if err != nil {
return 0, object, err
Expand Down

0 comments on commit 2e92a55

Please sign in to comment.