Documentation
¶
Overview ¶
Package db handles interactions with the MongoDB instance and works as an abstraction layer
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UpsertDocs ¶
func UpsertDocs[T any](ctx context.Context, c *Client, provider *DocsProvider[T])
UpsertDocs inserts or updates a list of documents based on their IDs.
Documents are matched by ID ("_id"). If a document with that ID already exists, it is updated. If it doesn't exist, it is inserted.
If an error occurs during upsert of one of the documents, processing continues. Thus, no error is returned.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the abstraction layer for the MongoDB connector
func (*Client) Disconnect ¶
Disconnect disconnects from the MongoDB instance
type CollectionName ¶
type CollectionName string
CollectionName is the name of a collection in the MongoDB database.
const ( // CollPlanets is the collection name for Planets CollPlanets CollectionName = "planets" // CollCampaigns is the collection name for Campaigns CollCampaigns CollectionName = "campaigns" // CollDispatches is the collection name for Dispatches CollDispatches CollectionName = "dispatches" // CollEvents is the collection name for Events CollEvents CollectionName = "events" // CollAssignments is the collection name for Assignments CollAssignments CollectionName = "assignments" // CollWars is the collection name for Wars CollWars CollectionName = "wars" // CollSnapshots is the collection name for Snapshots CollSnapshots CollectionName = "snapshots" )
type DocWrapper ¶
DocWrapper holds the document to be processed plus its document ID.
T should be the Document type.
type DocsProvider ¶
type DocsProvider[T any] struct { CollectionName CollectionName Docs []DocWrapper[T] }
DocsProvider wraps collection name and document slice for further processing.
T should be the Document type.