|
1 | 1 | package database |
2 | 2 |
|
| 3 | +import ( |
| 4 | + "context" |
| 5 | + |
| 6 | + "go.mongodb.org/mongo-driver/bson" |
| 7 | + "go.mongodb.org/mongo-driver/mongo" |
| 8 | +) |
| 9 | + |
3 | 10 | /* |
4 | 11 | Database interface exposing the methods necessary to querying, inserting, updating, upserting, and removing records |
5 | 12 | */ |
6 | 13 | type Database interface { |
7 | 14 | Connect(host string) error |
8 | 15 | Close() |
9 | | - FindOne(collection_name string, query interface{}, result interface{}) error |
10 | | - FindAll(collection_name string, query interface{}, result interface{}) error |
11 | | - FindAllSorted(collection_name string, query interface{}, sort_fields []SortField, result interface{}) error |
12 | | - RemoveOne(collection_name string, query interface{}) error |
13 | | - RemoveAll(collection_name string, query interface{}) (*ChangeResults, error) |
14 | | - Insert(collection_name string, item interface{}) error |
15 | | - Upsert(collection_name string, selector interface{}, update interface{}) (*ChangeResults, error) |
16 | | - Update(collection_name string, selector interface{}, update interface{}) error |
17 | | - UpdateAll(collection_name string, selector interface{}, update interface{}) (*ChangeResults, error) |
18 | | - DropDatabase() error |
19 | | - GetStats(collection_name string, fields []string) (map[string]interface{}, error) |
| 16 | + GetRaw() *mongo.Client |
| 17 | + StartSession() (*mongo.Session, error) |
| 18 | + GetNewContext() (context.Context, context.CancelFunc) |
| 19 | + FindOne(collection_name string, query interface{}, result interface{}, session *mongo.SessionContext) error |
| 20 | + FindOneAndDelete(collection_name string, query interface{}, result interface{}, session *mongo.SessionContext) error |
| 21 | + FindOneAndUpdate(collection_name string, query interface{}, update interface{}, result interface{}, return_new_doc bool, upsert bool, session *mongo.SessionContext) error |
| 22 | + FindOneAndReplace(collection_name string, query interface{}, update interface{}, result interface{}, return_new_doc bool, upsert bool, session *mongo.SessionContext) error |
| 23 | + FindAll(collection_name string, query interface{}, result interface{}, session *mongo.SessionContext) error |
| 24 | + FindAllSorted(collection_name string, query interface{}, sort_fields bson.D, result interface{}, session *mongo.SessionContext) error |
| 25 | + RemoveOne(collection_name string, query interface{}, session *mongo.SessionContext) error |
| 26 | + RemoveAll(collection_name string, query interface{}, session *mongo.SessionContext) (*ChangeResults, error) |
| 27 | + Insert(collection_name string, item interface{}, session *mongo.SessionContext) error |
| 28 | + Upsert(collection_name string, selector interface{}, update interface{}, session *mongo.SessionContext) (*ChangeResults, error) |
| 29 | + Update(collection_name string, selector interface{}, update interface{}, session *mongo.SessionContext) error |
| 30 | + UpdateAll(collection_name string, selector interface{}, update interface{}, session *mongo.SessionContext) (*ChangeResults, error) |
| 31 | + Replace(collection_name string, selector interface{}, update interface{}, upsert bool, session *mongo.SessionContext) error |
| 32 | + DropDatabase(session *mongo.SessionContext) error |
| 33 | + GetStats(collection_name string, fields []string, session *mongo.SessionContext) (map[string]interface{}, error) |
20 | 34 | } |
21 | 35 |
|
22 | 36 | /* |
|
0 commit comments