generated from mrz1836/go-template
-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
interface.go
59 lines (54 loc) · 2.26 KB
/
interface.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package datastore
import (
"context"
"time"
"go.mongodb.org/mongo-driver/mongo"
"gorm.io/gorm"
)
// StorageService is the storage related methods
type StorageService interface {
AutoMigrateDatabase(ctx context.Context, models ...interface{}) error
CreateInBatches(ctx context.Context, models interface{}, batchSize int) error
CustomWhere(tx CustomWhereInterface, conditions map[string]interface{}, engine Engine) interface{}
Execute(query string) *gorm.DB
GetModel(ctx context.Context, model interface{}, conditions map[string]interface{},
timeout time.Duration, forceWriteDB bool) error
GetModels(ctx context.Context, models interface{}, conditions map[string]interface{}, queryParams *QueryParams,
fieldResults interface{}, timeout time.Duration) error
GetModelCount(ctx context.Context, model interface{}, conditions map[string]interface{},
timeout time.Duration) (int64, error)
GetModelsAggregate(ctx context.Context, models interface{}, conditions map[string]interface{},
aggregateColumn string, timeout time.Duration) (map[string]interface{}, error)
HasMigratedModel(modelType string) bool
IncrementModel(ctx context.Context, model interface{},
fieldName string, increment int64) (newValue int64, err error)
IndexExists(tableName, indexName string) (bool, error)
IndexMetadata(tableName, field string) error
NewTx(ctx context.Context, fn func(*Transaction) error) error
NewRawTx() (*Transaction, error)
Raw(query string) *gorm.DB
SaveModel(ctx context.Context, model interface{}, tx *Transaction, newRecord, commitTx bool) error
}
// GetterInterface is the getter methods
type GetterInterface interface {
GetArrayFields() []string
GetDatabaseName() string
GetMongoCollection(collectionName string) *mongo.Collection
GetMongoCollectionByTableName(tableName string) *mongo.Collection
GetMongoConditionProcessor() func(conditions *map[string]interface{})
GetMongoIndexer() func() map[string][]mongo.IndexModel
GetObjectFields() []string
GetTableName(modelName string) string
}
// ClientInterface is the Datastore client interface
type ClientInterface interface {
GetterInterface
StorageService
Close(ctx context.Context) error
Debug(on bool)
DebugLog(ctx context.Context, text string)
Engine() Engine
IsAutoMigrate() bool
IsDebug() bool
IsNewRelicEnabled() bool
}