January 2019
Intermediate to advanced
520 pages
14h 32m
English
By tradition, we will use a Pool from the r2d2 crate, but in this example (as in the Redis example), we don't use multiple connections at once. Add all of the necessary dependencies to a new binary crate:
[dependencies]bson = "0.13"chrono = { version = "0.4", features = ["serde"] }clap = "2.32"failure = "0.1"mongodb = "0.3"r2d2 = "0.8"r2d2-mongodb = "0.1"serde = "1.0"serde_derive = "1.0"url = "1.7"
The list is not small. Besides the crates you already familiar with, we've added the bson, chrono, and url crates. The first crate we need to work with data in the database; the second, to use the Utc type; and the last to split URL strings into pieces.
Import all the necessary types, as follows:
use ...
Read now
Unlock full access