Dagger
Search

getFromMongo

This module is tailored for retrieving and aggregating transaction data from MongoDB using Atlas Search, a powerful full-text search engine integrated within MongoDB Atlas. It is designed to enhance financial analysis by grouping transactions by weeks and categories, facilitating a comprehensive overview of financial trends and spending behaviors.

The module leverages MongoDB's aggregation pipeline to dynamically group and summarize transaction data. It then formats this data into a structured JSON response that is easy to interpret and use in financial reporting or analysis applications.

Functions: - `authenticate`: A utility function to authenticate with MongoDB using provided credentials and obtain a reference to a specific transactions collection. This function is critical for establishing a secure and reliable connection to the database. - `get_data`: The primary function of this module. It retrieves transaction data, processes it through MongoDB's aggregation pipeline, and returns it grouped by weeks and categories.

Args: - `connection (Secret)`: A Secret object that stores the MongoDB connection string. This should have sufficient privileges to access and execute aggregation commands on the specified database and collection. - `database (str)`: The name of the MongoDB database that contains the transactions collection. - `collection (str)`: The specific collection within the database from which transaction data is retrieved.

Return: - The `get_data` function outputs a JSON string. This string represents an organized collection of data with transactions grouped by weeks and within each week by categories. Each category contains a list of transactions and the total amount spent in that category for the week, alongside the total spent for the entire week.

Example Call: `dagger call get-data --connection=env:[KEY] --database=[DBNAME] --collection=[COLLECTIONNAME]`

This module simplifies complex financial data aggregation tasks and presents them in an easily accessible format, making it an invaluable tool for businesses that need to perform regular financial reviews or audits.

Installation

dagger install github.com/EmmS21/daggerverse/getFromMongo@v0.0.1

Entrypoint

Return Type
GetFromMongo !
Example
func (m *myModule) example() *GetFromMongo  {
	return dag.
			GetFromMongo()
}
@function
def example() -> dag.GetFromMongo:
	return (
		dag.get_from_mongo()
	)
@func()
example(): GetFromMongo {
	return dag
		.getFromMongo()
}

Types

GetFromMongo 🔗

getData() 🔗

Return Type
String !
Arguments
NameTypeDefault ValueDescription
connectionSecret !-A reference to a secret value, which can be handled more safely than the value itself.
databaseString !-No description provided
collectionString !-No description provided
Example
dagger -m github.com/EmmS21/daggerverse/getFromMongo@93c85c21fd39b24a8691ad7a6a47f3c94fdde1d5 call \
 get-data --connection env:MYSECRET --database string --collection string
func (m *myModule) example(ctx context.Context, connection *Secret, database string, collection string) string  {
	return dag.
			GetFromMongo().
			GetData(ctx, connection, database, collection)
}
@function
async def example(connection: dagger.Secret, database: str, collection: str) -> str:
	return await (
		dag.get_from_mongo()
		.get_data(connection, database, collection)
	)
@func()
async example(connection: Secret, database: string, collection: string): Promise<string> {
	return dag
		.getFromMongo()
		.getData(connection, database, collection)
}