From e7242e1cbc042630c846669f837bc8f62a9e0c97 Mon Sep 17 00:00:00 2001 From: Andrew Sisley Date: Thu, 14 Sep 2023 10:37:22 -0400 Subject: [PATCH] PR FIXUP - Correct document key before transmission --- http/client_collection.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/http/client_collection.go b/http/client_collection.go index 713d45d2bf..16157a9f96 100644 --- a/http/client_collection.go +++ b/http/client_collection.go @@ -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 @@ -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