Add onboarding and FromRequest for User.

This commit is contained in:
Paul Makles
2020-12-28 21:47:32 +00:00
parent 16c5a28637
commit 798047625a
13 changed files with 236 additions and 88 deletions

View File

@@ -10,28 +10,28 @@ pub async fn create_database() {
let db = get_db();
db.create_collection("users", None)
.await
.expect("Failed to create users collection.");
.await
.expect("Failed to create users collection.");
db.create_collection("channels", None)
.await
.expect("Failed to create channels collection.");
.await
.expect("Failed to create channels collection.");
db.create_collection("guilds", None)
.await
.expect("Failed to create guilds collection.");
.await
.expect("Failed to create guilds collection.");
db.create_collection("members", None)
.await
.expect("Failed to create members collection.");
.await
.expect("Failed to create members collection.");
db.create_collection("messages", None)
.await
.expect("Failed to create messages collection.");
.await
.expect("Failed to create messages collection.");
db.create_collection("migrations", None)
.await
.expect("Failed to create migrations collection.");
.await
.expect("Failed to create migrations collection.");
db.create_collection(
"pubsub",
@@ -40,19 +40,41 @@ pub async fn create_database() {
.size(1_000_000)
.build(),
)
.await
.expect("Failed to create pubsub collection.");
.await
.expect("Failed to create pubsub collection.");
db.run_command(
doc! {
"createIndexes": "users",
"indexes": [
{
"key": {
"username": 1
},
"name": "username",
"unique": true,
"collation": {
"locale": "en",
"strength": 2
}
}
]
},
None
)
.await
.expect("Failed to create username index.");
db.collection("migrations")
.insert_one(
doc! {
"_id": 0,
"revision": LATEST_REVISION
},
None,
)
.await
.expect("Failed to save migration info.");
.insert_one(
doc! {
"_id": 0,
"revision": LATEST_REVISION
},
None,
)
.await
.expect("Failed to save migration info.");
info!("Created database.");
}