fixed doc env vars + mongo v2 migration
This commit is contained in:
@@ -8,7 +8,7 @@ import (
|
||||
"github.com/tech/sendico/pkg/mlogger"
|
||||
"github.com/tech/sendico/pkg/model"
|
||||
"github.com/tech/sendico/pkg/mutil/mzap"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
@@ -36,7 +36,7 @@ func NewArchivableDB[T storable.Storable](
|
||||
}
|
||||
|
||||
// SetArchived sets the archived status of an entity
|
||||
func (db *ArchivableDB[T]) SetArchived(ctx context.Context, objectRef primitive.ObjectID, archived bool) error {
|
||||
func (db *ArchivableDB[T]) SetArchived(ctx context.Context, objectRef bson.ObjectID, archived bool) error {
|
||||
// Get current object to check current archived status
|
||||
obj := db.createEmpty()
|
||||
if err := db.repo.Get(ctx, objectRef, obj); err != nil {
|
||||
@@ -74,7 +74,7 @@ func (db *ArchivableDB[T]) SetArchived(ctx context.Context, objectRef primitive.
|
||||
}
|
||||
|
||||
// IsArchived checks if an entity is archived
|
||||
func (db *ArchivableDB[T]) IsArchived(ctx context.Context, objectRef primitive.ObjectID) (bool, error) {
|
||||
func (db *ArchivableDB[T]) IsArchived(ctx context.Context, objectRef bson.ObjectID) (bool, error) {
|
||||
obj := db.createEmpty()
|
||||
|
||||
if err := db.repo.Get(ctx, objectRef, obj); err != nil {
|
||||
@@ -89,11 +89,11 @@ func (db *ArchivableDB[T]) IsArchived(ctx context.Context, objectRef primitive.O
|
||||
}
|
||||
|
||||
// Archive archives an entity (sets archived to true)
|
||||
func (db *ArchivableDB[T]) Archive(ctx context.Context, objectRef primitive.ObjectID) error {
|
||||
func (db *ArchivableDB[T]) Archive(ctx context.Context, objectRef bson.ObjectID) error {
|
||||
return db.SetArchived(ctx, objectRef, true)
|
||||
}
|
||||
|
||||
// Unarchive unarchives an entity (sets archived to false)
|
||||
func (db *ArchivableDB[T]) Unarchive(ctx context.Context, objectRef primitive.ObjectID) error {
|
||||
func (db *ArchivableDB[T]) Unarchive(ctx context.Context, objectRef bson.ObjectID) error {
|
||||
return db.SetArchived(ctx, objectRef, false)
|
||||
}
|
||||
|
||||
@@ -8,16 +8,16 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/tech/sendico/pkg/db/internal/mongo/repositoryimp"
|
||||
"github.com/tech/sendico/pkg/db/storable"
|
||||
"github.com/tech/sendico/pkg/model"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/testcontainers/testcontainers-go"
|
||||
"github.com/testcontainers/testcontainers-go/modules/mongodb"
|
||||
"github.com/testcontainers/testcontainers-go/wait"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
"go.mongodb.org/mongo-driver/v2/mongo"
|
||||
"go.mongodb.org/mongo-driver/v2/mongo/options"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user