📜  在 MongoDB 部署中将文档插入数据库中的集合 - 任何代码示例

📅  最后修改于: 2022-03-11 14:59:42.645000             🧑  作者: Mango

代码示例1
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?;