![]() ![]() -d, which is a shortcut for –detach, runs the container in the background and prints the container ID.Otherwise, a random one will be generated with –name we assign our custom name to the container.Let’s open up the terminal and specify the following command: docker run -name my_mongodb_cotainer -d -p 27017:27017 mongo:5.0.6īasically, this with this one-liner we perform a few actions: With all of the above being done, let’s prepare a MongoDB instance with Docker. Implementation(":kmongo:$kmongo_version") 4. Adjust Ktor SettingsĪs the first step, let’s make sure that we set correctly the required properties:Īfter we import the project, let’s head to the gradle.properties file and specify the version of KMongo we’d like to use: kmongo_version=4.5.0įollowing, let’s open the file and put the following lines: val kmongo_version: String by project With that being said, let’s head to the Ktor Project Generator page and make a few adjustments.Īlternatively, you can generate the project within the app if you use IntelliJ IDEA Ultimate Edition 2.1. Otherwise, please make sure that you have configured Docker properly in your local environment. If you have MongoDB already installed on your local machine, then you can just skip this part. In this article, I will show you how to create MongoDB as a Docker container. In the end, I would like to add one more note. With this combination, we are sure that we’re using the recommended Java Driver, and additionally, we take advantage of the Kotlin less-verbose syntax. Internally, it uses the core MongoDB Java Driver and exposes its features via Kotlin extensions. If you haven’t heard about KMongo yet- it is a lightweight Kotlin toolkit for Mongo. ![]() In this step-by-step guide, I would like to show you how to implement a REST API using Ktor, MongoDB, and KMongo.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |