Skip to content

Commit

Permalink
PR FIXUP - Correct document key before transmission
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewSisley committed Sep 14, 2023
1 parent 1856080 commit b859dc7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions http/client_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ func (c *Collection) SchemaID() string {
func (c *Collection) Create(ctx context.Context, doc *client.Document) error {
methodURL := c.http.baseURL.JoinPath("collections", c.desc.Name)

// We must call this here, else the doc key on the given object will not match
// that of the document saved in the database
err := doc.RemapAliasFieldsAndDockey(c.Description().Schema.Fields)
if err != nil {
return err
}

body, err := doc.String()
if err != nil {
return err
Expand All @@ -79,6 +86,13 @@ func (c *Collection) CreateMany(ctx context.Context, docs []*client.Document) er

var docMapList []json.RawMessage
for _, doc := range docs {
// We must call this here, else the doc key on the given object will not match
// that of the document saved in the database
err := doc.RemapAliasFieldsAndDockey(c.Description().Schema.Fields)
if err != nil {
return err
}

docMap, err := documentJSON(doc)
if err != nil {
return err
Expand Down

0 comments on commit b859dc7

Please sign in to comment.