Created
December 22, 2016 00:44
-
-
Save saghm/c90d9178975a77caa8b6eeb0f7955a29 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate mongodb; | |
#[macro_use] extern crate bson; | |
use mongodb::{Client, ClientOptions, ThreadedClient}; | |
use mongodb::db::ThreadedDatabase; | |
fn main(){ | |
let options = ClientOptions::with_log_file("/tmp/mongo-commands"); | |
let client = Client::connect_with_options("domain.name", 27017, options).expect("Couldn't connect to mongodb database"); | |
let database = client.db("db"); | |
database.auth("user", "password").expect("Can't authenticate to database"); | |
let collection = database.collection("collection"); | |
let doc = doc! { "test" => "test" }; | |
collection.insert_one(doc, None).expect("Couldn't insert a document"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment