From 31b5d063305a2848bb00b45c99889cfb9b2cc864 Mon Sep 17 00:00:00 2001 From: Andrew Sisley Date: Thu, 31 Oct 2024 14:27:02 -0400 Subject: [PATCH] WIP - Remove unused return param from col.save --- internal/db/collection.go | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/internal/db/collection.go b/internal/db/collection.go index af631701fc..5d988bdb58 100644 --- a/internal/db/collection.go +++ b/internal/db/collection.go @@ -17,7 +17,6 @@ import ( "strconv" "strings" - "github.com/ipfs/go-cid" ds "github.com/ipfs/go-datastore" "github.com/ipfs/go-datastore/query" cidlink "github.com/ipld/go-ipld-prime/linking/cid" @@ -467,7 +466,7 @@ func (c *collection) create( } // write data to DB via MerkleClock/CRDT - _, err = c.save(ctx, doc, true) + err = c.save(ctx, doc, true) if err != nil { return err } @@ -535,7 +534,7 @@ func (c *collection) update( return client.ErrDocumentNotFoundOrNotAuthorized } - _, err = c.save(ctx, doc, false) + err = c.save(ctx, doc, false) if err != nil { return err } @@ -605,15 +604,15 @@ func (c *collection) save( ctx context.Context, doc *client.Document, isCreate bool, -) (cid.Cid, error) { +) error { if err := c.validateEncryptedFields(ctx); err != nil { - return cid.Undef, err + return err } if !isCreate { err := c.updateIndexedDoc(ctx, doc) if err != nil { - return cid.Undef, err + return err } } txn := mustGetContextTxn(ctx) @@ -637,19 +636,19 @@ func (c *collection) save( for k, v := range doc.Fields() { val, err := doc.GetValueWithField(v) if err != nil { - return cid.Undef, err + return err } if val.IsDirty() { fieldKey, fieldExists := c.tryGetFieldKey(primaryKey, k) if !fieldExists { - return cid.Undef, client.NewErrFieldNotExist(k) + return client.NewErrFieldNotExist(k) } fieldDescription, valid := c.Definition().GetFieldByName(k) if !valid { - return cid.Undef, client.NewErrFieldNotExist(k) + return client.NewErrFieldNotExist(k) } // by default the type will have been set to LWW_REGISTER. We need to ensure @@ -663,7 +662,7 @@ func (c *collection) save( val.Value(), ) if err != nil { - return cid.Undef, err + return err } merkleCRDT, err := merklecrdt.InstanceWithStore( @@ -675,12 +674,12 @@ func (c *collection) save( fieldDescription.Name, ) if err != nil { - return cid.Undef, err + return err } link, _, err := merkleCRDT.Save(ctx, merklecrdt.NewDocField(primaryKey.DocID, k, val)) if err != nil { - return cid.Undef, err + return err } links = append(links, coreblock.NewDAGLink(k, link)) @@ -694,7 +693,7 @@ func (c *collection) save( client.Active, ) if err != nil { - return cid.Undef, err + return err } // publish an update event when the txn succeeds @@ -712,7 +711,7 @@ func (c *collection) save( doc.SetHead(link.Cid) }) - return link.Cid, nil + return nil } func (c *collection) validateOneToOneLinkDoesntAlreadyExist(