Skip to content

Commit

Permalink
feat: add mongoDB to storage
Browse files Browse the repository at this point in the history
  • Loading branch information
gulivero1773 committed Mar 7, 2024
1 parent 3f4aa59 commit f186941
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,22 @@ extension Application {
app.mongoCluster = try await MongoCluster(connectingTo: ConnectionSettings(connectionString))
*/
}

extension Application {
/// A `MongoDBKey` conform to StorageKey protocol
public struct MongoDBKey: StorageKey {
/// Less verbose typealias for `MongoDatabase`.
public typealias Value = MongoDatabase
}

/// Setup `mongoDB` in application storage
public var mongoDB: MongoDatabase? {
get { storage[MongoDBKey.self] }
set { storage[MongoDBKey.self] = newValue }
}

/*
/// For example setup mongo database need use method like this:
app.mongoDB = try await try MongoDatabase.lazyConnect(to: connectionString)
*/
}

0 comments on commit f186941

Please sign in to comment.