Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MongoInstance ¶
Description:
A MongoDB instance. A wrapper around the MongoDB client.
func NewMongoInstance ¶
func NewMongoInstance(uri string) (*MongoInstance, error)
Description:
Creates a new mongo instance. Connects instantly to the given URI.
Parameters:
uri The MongoDB connection URI.
Returns:
The created mongo instance, or an error, if the connection fails.
type MongoStore ¶
type MongoStore[T interface{}] struct { // The MongoDB collection. Collection *mongo.Collection }
Description:
A MongoDB store. A wrapper around the MongoDB collection.
func NewMongoStore ¶
func NewMongoStore[T interface{}](instance *MongoInstance, database string, collection string) *MongoStore[T]
Description:
Creates a new mongo store.
Parameters:
instance The mongo instance which is referred to. database The mongo database name referring to. collection The mongo collection name referring to.
Type Parameters:
T The type of document stored in the mongo store to create.
Returns:
The created mongo store.
func (*MongoStore[T]) CreateItem ¶
func (store *MongoStore[T]) CreateItem(item interface{}) error
Description:
Creates a new item.
Parameters:
item The item to create.
Returns:
An error if creation fails.
func (MongoStore[T]) DeleteItem ¶
func (store MongoStore[T]) DeleteItem(id string) (int64, error)
Description:
Deletes an item by its ID.
Parameters:
The ID of the document to delete.
Returns:
The number of deleted documents. An error if the request fails.
func (*MongoStore[T]) FindItems ¶
func (store *MongoStore[T]) FindItems(filter *query.Filter) ([]T, error)
Description:
Queries items in the store.
Parameters:
The query filter to use.
Returns:
An array of all items matching the given query filter. An error if the query fails.
func (*MongoStore[T]) UpdateItem ¶
Description:
Updates a single item.
Parameters:
filter The filter used for searching the documents to update. update The update operator used for updating the filtered documents.
Returns:
The number of modified documents. An error if the update fails.
Click to show internal directories.
Click to hide internal directories.