Initial commit: Open sourcing all of the Maple Open Technologies code.
This commit is contained in:
commit
755d54a99d
2010 changed files with 448675 additions and 0 deletions
|
|
@ -0,0 +1,37 @@
|
|||
// monorepo/cloud/maplefile-backend/internal/maplefile/repo/collection/hierarchy.go
|
||||
package collection
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/gocql/gocql"
|
||||
)
|
||||
|
||||
func (impl *collectionRepositoryImpl) MoveCollection(
|
||||
ctx context.Context,
|
||||
collectionID,
|
||||
newParentID gocql.UUID,
|
||||
updatedAncestors []gocql.UUID,
|
||||
updatedPathSegments []string,
|
||||
) error {
|
||||
// Get the collection
|
||||
collection, err := impl.Get(ctx, collectionID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get collection: %w", err)
|
||||
}
|
||||
|
||||
if collection == nil {
|
||||
return fmt.Errorf("collection not found")
|
||||
}
|
||||
|
||||
// Update hierarchy information
|
||||
collection.ParentID = newParentID
|
||||
collection.AncestorIDs = updatedAncestors
|
||||
collection.ModifiedAt = time.Now()
|
||||
collection.Version++
|
||||
|
||||
// Single update call handles all the complexity with the optimized schema
|
||||
return impl.Update(ctx, collection)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue