Skip to content

Instantly share code, notes, and snippets.

@gdhuper
Created April 22, 2020 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gdhuper/33596a342212fa9a521ea02ded7d9d1e to your computer and use it in GitHub Desktop.
Save gdhuper/33596a342212fa9a521ea02ded7d9d1e to your computer and use it in GitHub Desktop.
cosmos-rust-getting-started-db-create
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