Created
April 22, 2020 22:25
-
-
Save gdhuper/33596a342212fa9a521ea02ded7d9d1e to your computer and use it in GitHub Desktop.
cosmos-rust-getting-started-db-create
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
fn create(&self, doc: Document) -> Result<Bson, Error> { | |
let collection = &self | |
.client | |
.get_db(&self.database) | |
.get_collection(&self.collection); | |
// inserts the given document in the collection | |
match collection.insert_one(doc, None) { | |
Ok(result) => Ok(result.inserted_id), | |
Err(e) => Err(e), | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment