📅  最后修改于: 2022-03-11 14:59:42.645000             🧑  作者: Mango
use mongodb::bson::{doc, Document};
// Get a handle to a collection in the database.
let collection = db.collection::("books");
let docs = vec![
doc! { "title": "1984", "author": "George Orwell" },
doc! { "title": "Animal Farm", "author": "George Orwell" },
doc! { "title": "The Great Gatsby", "author": "F. Scott Fitzgerald" },
];
// Insert some documents into the "mydb.books" collection.
collection.insert_many(docs, None).await?;