@@ -28,7 +28,7 @@ func (d Database[T]) Create(col string, data T) (inserted T, err error) {
28
28
return
29
29
}
30
30
31
- doc , err = datastore .CreateDocument (d .auth , d .conf .Name , col , doc )
31
+ doc , err = DB .CreateDocument (d .auth , d .conf .Name , col , doc )
32
32
if err != nil {
33
33
return
34
34
}
@@ -48,7 +48,7 @@ func (d Database[T]) BulkCreate(col string, entities []T) error {
48
48
49
49
docs = append (docs , x )
50
50
}
51
- return datastore .BulkCreateDocument (d .auth , d .conf .Name , col , docs )
51
+ return DB .BulkCreateDocument (d .auth , d .conf .Name , col , docs )
52
52
}
53
53
54
54
// PageResult wraps a slice of type T with paging information
@@ -61,7 +61,7 @@ type PagedResult[T any] struct {
61
61
62
62
// List returns records from a collection/repository using paging/sorting params
63
63
func (d Database [T ]) List (col string , lp model.ListParams ) (res PagedResult [T ], err error ) {
64
- r , err := datastore .ListDocuments (d .auth , d .conf .Name , col , lp )
64
+ r , err := DB .ListDocuments (d .auth , d .conf .Name , col , lp )
65
65
if err != nil {
66
66
return
67
67
}
@@ -84,12 +84,12 @@ func (d Database[T]) List(col string, lp model.ListParams) (res PagedResult[T],
84
84
85
85
// Query returns records that match with the provided filters.
86
86
func (d Database [T ]) Query (col string , filters [][]any , lp model.ListParams ) (res PagedResult [T ], err error ) {
87
- clauses , err := datastore .ParseQuery (filters )
87
+ clauses , err := DB .ParseQuery (filters )
88
88
if err != nil {
89
89
return
90
90
}
91
91
92
- r , err := datastore .QueryDocuments (d .auth , d .conf .Name , col , clauses , lp )
92
+ r , err := DB .QueryDocuments (d .auth , d .conf .Name , col , clauses , lp )
93
93
if err != nil {
94
94
return
95
95
}
@@ -112,7 +112,7 @@ func (d Database[T]) Query(col string, filters [][]any, lp model.ListParams) (re
112
112
113
113
// GetByID returns a specific record from a collection/repository
114
114
func (d Database [T ]) GetByID (col , id string ) (entity T , err error ) {
115
- doc , err := datastore .GetDocumentByID (d .auth , d .conf .Name , col , id )
115
+ doc , err := DB .GetDocumentByID (d .auth , d .conf .Name , col , id )
116
116
if err != nil {
117
117
return
118
118
}
@@ -128,7 +128,7 @@ func (d Database[T]) Update(col, id string, v any) (entity T, err error) {
128
128
return
129
129
}
130
130
131
- x , err := datastore .UpdateDocument (d .auth , d .conf .Name , col , id , doc )
131
+ x , err := DB .UpdateDocument (d .auth , d .conf .Name , col , id , doc )
132
132
if err != nil {
133
133
return
134
134
}
@@ -139,7 +139,7 @@ func (d Database[T]) Update(col, id string, v any) (entity T, err error) {
139
139
140
140
// UpdateMany updates multiple records matching filters
141
141
func (d Database [T ]) UpdateMany (col string , filters [][]any , v any ) (int64 , error ) {
142
- clauses , err := datastore .ParseQuery (filters )
142
+ clauses , err := DB .ParseQuery (filters )
143
143
if err != nil {
144
144
return 0 , err
145
145
}
@@ -148,17 +148,17 @@ func (d Database[T]) UpdateMany(col string, filters [][]any, v any) (int64, erro
148
148
if err != nil {
149
149
return 0 , err
150
150
}
151
- return datastore .UpdateDocuments (d .auth , d .conf .Name , col , clauses , doc )
151
+ return DB .UpdateDocuments (d .auth , d .conf .Name , col , clauses , doc )
152
152
}
153
153
154
154
// IncrementValue increments or decrements a specifc field from a collection/repository
155
155
func (d Database [T ]) IncrementValue (col , id , field string , n int ) error {
156
- return datastore .IncrementValue (d .auth , d .conf .Name , col , id , field , n )
156
+ return DB .IncrementValue (d .auth , d .conf .Name , col , id , field , n )
157
157
}
158
158
159
159
// Delete removes a record from a collection
160
160
func (d Database [T ]) Delete (col , id string ) (int64 , error ) {
161
- return datastore .DeleteDocument (d .auth , d .conf .Name , col , id )
161
+ return DB .DeleteDocument (d .auth , d .conf .Name , col , id )
162
162
}
163
163
164
164
func toDoc (v any ) (doc map [string ]any , err error ) {
0 commit comments