Skip to content

Commit

Permalink
rename idFieldName const to _id
Browse files Browse the repository at this point in the history
Signed-off-by: requilence <[email protected]>
  • Loading branch information
requilence committed May 1, 2020
1 parent ef1b33c commit 9e4577a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions db/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,15 +469,15 @@ func getInstanceID(t []byte) core.InstanceID {

func setNewInstanceID(t []byte) (core.InstanceID, []byte) {
newID := core.NewInstanceID()
patchedValue, err := jsonpatch.MergePatch(t, []byte(fmt.Sprintf(`{"_id": %q}`, newID.String())))
patchedValue, err := jsonpatch.MergePatch(t, []byte(fmt.Sprintf(`{"%s": %q}`, idFieldName, newID.String())))
if err != nil {
log.Fatalf("error while automatically patching autogenerated _id: %v", err)
}
return newID, patchedValue
}

func hasIDProperty(properties map[string]*jsonschema.Type) bool {
idProperty := properties["_id"]
idProperty := properties[idFieldName]
if idProperty == nil || idProperty.Type != "string" {
return false
}
Expand Down
2 changes: 1 addition & 1 deletion db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
)

const (
idFieldName = "ID"
idFieldName = "_id"
getBlockRetries = 3
getBlockInitialTimeout = time.Millisecond * 500
)
Expand Down

0 comments on commit 9e4577a

Please sign in to comment.