Documentation ¶
Index ¶
- type Collection
- type TestConnection
- func (c *TestConnection) Count(entry db.Entry, filter bson.M) (uint64, error)
- func (c *TestConnection) DeleteByID(entry db.Entry, ids ...primitive.ObjectID) error
- func (c *TestConnection) Dump(shouldPanic bool)
- func (c *TestConnection) DumpCollection(entry db.Entry, shouldPanic bool)
- func (c *TestConnection) Find(base db.Entry, results any, filters bson.M, optionalOpts ...db.FindOptions) error
- func (c *TestConnection) FindOne(placeInto db.Entry, filters bson.M, optionalOpts ...db.FindOptions) error
- func (c *TestConnection) Insert(data ...db.Entry) error
- func (*TestConnection) RegisterEntries(...db.Entry)
- func (c *TestConnection) UnsafeInsert(entries ...db.Entry) error
- func (c *TestConnection) UpdateByID(updateData db.Entry) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
Collection contains all the data for a collection
type TestConnection ¶
type TestConnection struct {
// contains filtered or unexported fields
}
TestConnection is the struct that implements db.Connection
func NewDB ¶
func NewDB() *TestConnection
NewDB returns a testing database connection that is compatible with db.Connection
func (*TestConnection) DeleteByID ¶
DeleteByID deletes a document by it's ID
func (*TestConnection) Dump ¶
func (c *TestConnection) Dump(shouldPanic bool)
Dump prints the full database contents in the console This can be used in tests to dump the contents of the database might something fail or to debug
shouldPanic controls if the output is only printed or also should panic
func (*TestConnection) DumpCollection ¶
func (c *TestConnection) DumpCollection(entry db.Entry, shouldPanic bool)
DumpCollection prints a full database collection it's contents in the console This can be used in tests to dump the contents of the database might something fail or to debug
shouldPanic controls if the output is only printed or also should panic
func (*TestConnection) Find ¶
func (c *TestConnection) Find(base db.Entry, results any, filters bson.M, optionalOpts ...db.FindOptions) error
Find finds documents in the collection of the base The results can be filtered using filters The filters should work equal to MongoDB filters (https://docs.mongodb.com/manual/tutorial/query-documents/) tough this might miss features compared to mongoDB's filters
func (*TestConnection) FindOne ¶
func (c *TestConnection) FindOne(placeInto db.Entry, filters bson.M, optionalOpts ...db.FindOptions) error
FindOne finds one document in the collection of placeInto The result can be filtered using filters The filters should work equal to MongoDB filters (https://docs.mongodb.com/manual/tutorial/query-documents/) tough this might miss features compared to mongoDB's filters
func (*TestConnection) Insert ¶
func (c *TestConnection) Insert(data ...db.Entry) error
Insert inserts an item into the database Implements db.Connection
func (*TestConnection) RegisterEntries ¶
func (*TestConnection) RegisterEntries(...db.Entry)
RegisterEntries implements db.Connection We don't need to implement this function
func (*TestConnection) UnsafeInsert ¶
func (c *TestConnection) UnsafeInsert(entries ...db.Entry) error
UnsafeInsert inserts data directly into the database !!Be aware!!: - Not thread safe - Assumes the all entries are of same type / collection
func (*TestConnection) UpdateByID ¶
func (c *TestConnection) UpdateByID(updateData db.Entry) error
UpdateByID updates a document in the database by its ID