Skip to content

Commit

Permalink
changed mongodb repository to accept any interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Danushka96 committed Dec 12, 2024
1 parent e084fb1 commit aa6eefc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
3 changes: 0 additions & 3 deletions mongo_document.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import (
"unicode"
)

type Document interface {
}

// getDocumentID returns the ID value of a document using reflection
// It looks for a field tagged with `ginboot:"_id"` or falls back to a field named "ID"
func getDocumentID(doc interface{}) string {
Expand Down
4 changes: 2 additions & 2 deletions mongo_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
"go.mongodb.org/mongo-driver/mongo/options"
)

type MongoRepository[T Document] struct {
type MongoRepository[T interface{}] struct {
collection *mongo.Collection
}

func NewMongoRepository[T Document](db *mongo.Database) *MongoRepository[T] {
func NewMongoRepository[T interface{}](db *mongo.Database) *MongoRepository[T] {
var doc T
return &MongoRepository[T]{
collection: db.Collection(getCollectionName(doc)),
Expand Down

0 comments on commit aa6eefc

Please sign in to comment.