-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changed ID field from interface to string
- Loading branch information
1 parent
12b6c73
commit ca8e743
Showing
4 changed files
with
144 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,58 @@ | ||
package ginboot | ||
|
||
type GenericRepository[T Document] interface { | ||
FindById(id interface{}) (T, error) | ||
FindAllById(ids []interface{}) ([]T, error) | ||
// GenericRepository defines the interface for a generic repository with string IDs | ||
type GenericRepository[T any] interface { | ||
// FindById finds a document by its string ID | ||
FindById(id string) (T, error) | ||
|
||
// FindAllById finds all documents with the given string IDs | ||
FindAllById(ids []string) ([]T, error) | ||
|
||
// Save saves a document | ||
Save(doc T) error | ||
|
||
// SaveOrUpdate saves or updates a document | ||
SaveOrUpdate(doc T) error | ||
|
||
// SaveAll saves multiple documents | ||
SaveAll(docs []T) error | ||
|
||
// Update updates an existing document | ||
Update(doc T) error | ||
Delete(id interface{}) error | ||
|
||
// Delete deletes a document by its string ID | ||
Delete(id string) error | ||
|
||
// FindOneBy finds a document by a field value | ||
FindOneBy(field string, value interface{}) (T, error) | ||
|
||
// FindOneByFilters finds a document by multiple filters | ||
FindOneByFilters(filters map[string]interface{}) (T, error) | ||
|
||
// FindBy finds documents by a field value | ||
FindBy(field string, value interface{}) ([]T, error) | ||
|
||
// FindByFilters finds documents by multiple filters | ||
FindByFilters(filters map[string]interface{}) ([]T, error) | ||
|
||
// FindAll finds all documents | ||
FindAll(options ...interface{}) ([]T, error) | ||
|
||
// FindAllPaginated finds all documents with pagination | ||
FindAllPaginated(pageRequest PageRequest) (PageResponse[T], error) | ||
|
||
// FindByPaginated finds documents by filters with pagination | ||
FindByPaginated(pageRequest PageRequest, filters map[string]interface{}) (PageResponse[T], error) | ||
|
||
// CountBy counts documents by a field value | ||
CountBy(field string, value interface{}) (int64, error) | ||
|
||
// CountByFilters counts documents by multiple filters | ||
CountByFilters(filters map[string]interface{}) (int64, error) | ||
|
||
// ExistsBy checks if a document exists by a field value | ||
ExistsBy(field string, value interface{}) (bool, error) | ||
|
||
// ExistsByFilters checks if a document exists by multiple filters | ||
ExistsByFilters(filters map[string]interface{}) (bool, error) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.