Using Docker Compose ( docker-compose.yml):ĭocker compose up (or docker-compose up in older Docker versions) You can test the functions using REST API methods:Įrror handling is implemented accordingly with the documentation.įor launching the project locally you have two options:
I won’t stop in detail on these functions due to the obvious code of their implementation.
The project also contains examples on how to get, create, update, and delete MongoDB documents.
Mongofiles -host mongodb -db solar_system_info -authenticationDatabase admin -username $MONGODB_USERNAME -password $MONGODB_PASSWORD put /mongodb-init/images/*.jpgīut then it turned out that the images can’t be read from the database due to the lack of GridFS support in MongoDB Rust Driver ( open ticket). My first thought was to store them in MongoDB that can be performed using the following command: The application also serves images of planets. This section doesn’t require Rust skills and can be used regardless of a programming language used in an application.īoth tools can be launched as Docker containers:Įnter fullscreen mode Exit fullscreen modeĪlso, the database initialization can be performed using JavaScript file. The domain model includes data about planets in the Solar System and their satellites. You will also be able to test REST API of the application: it is deployed on Google Cloud Platform. The project is implemented with MongoDB Rust driver and redis-rs crate. First of all, the examples are intended to familiarize you with MongoDB and Redis. Please note that the specified use cases don’t mean that for a similar use case you should use an approach given in this article.
Finally, the following architecture will be obtained: For visibility purposes, created demo application will also be a web application that exposes REST API. This guide will show you how to create a Rust web backend that uses MongoDB, a document-based database, to store data and Redis for caching, rate limiting, and notifications.