Switch to async Rust and break all logic.

This commit is contained in:
Paul Makles
2020-12-27 13:28:37 +00:00
parent 5711986768
commit 6cfec0ee08
26 changed files with 1141 additions and 1256 deletions

View File

@@ -5,21 +5,32 @@ use log::info;
use mongodb::bson::doc;
use mongodb::options::CreateCollectionOptions;
pub fn create_database() {
pub async fn create_database() {
info!("Creating database.");
let db = get_db();
db.create_collection("users", None)
.await
.expect("Failed to create users collection.");
db.create_collection("channels", None)
.await
.expect("Failed to create channels collection.");
db.create_collection("guilds", None)
.await
.expect("Failed to create guilds collection.");
db.create_collection("members", None)
.await
.expect("Failed to create members collection.");
db.create_collection("messages", None)
.await
.expect("Failed to create messages collection.");
db.create_collection("migrations", None)
.await
.expect("Failed to create migrations collection.");
db.create_collection(
@@ -29,7 +40,8 @@ pub fn create_database() {
.size(1_000_000)
.build(),
)
.expect("Failed to create pubsub collection.");
.await
.expect("Failed to create pubsub collection.");
db.collection("migrations")
.insert_one(
@@ -39,6 +51,7 @@ pub fn create_database() {
},
None,
)
.await
.expect("Failed to save migration info.");
info!("Created database.");