Skip to content

Latest commit

 

History

History
27 lines (19 loc) · 1.01 KB

obtaining_collections.md

File metadata and controls

27 lines (19 loc) · 1.01 KB

Obtaining Collections

To obtain a collection, we use collection of Database.

let db = Database::open_memory().unwrap();
let collection = db.collection("name_of_the_collection");

If we do not know the name of a collection, we can use list_collection_names of Database to see all the collection names.

let db = Database::open_memory().unwrap();
db.create_collection("collection 1").unwrap();
db.create_collection("collection 2").unwrap();
println!("{:?}", db.list_collection_names());

Output:

Ok(["collection 1", "collection 2"])

➡️ Next: Dropping Collections

📘 Back: Table of contents