Skip to content

Commit

Permalink
allow passing DB/Collection to MongoSessionStore
Browse files Browse the repository at this point in the history
  • Loading branch information
WebFreak001 committed Feb 5, 2024
1 parent 6d717c9 commit d7acc12
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion mongodb/vibe/db/mongo/sessionstore.d
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ final class MongoSessionStore : SessionStore {
Params:
url = URL of the MongoDB database (e.g. `"mongodb://localhost/mydb"`)
database = Name of the database to use
collection = Optional collection name to store the sessions in
*/
this(string url, string collection = "sessions")
Expand All @@ -66,6 +65,27 @@ final class MongoSessionStore : SessionStore {
m_sessions = db[collection];
}

/** Constructs a new MongoDB session store using an existing DB.
Params:
db = the connected MongoDB database.
collection = the collection name for the sessions collection.
*/
this(MongoDatabase db, string collection = "sessions")
{
m_sessions = db[collection];
}

/** Constructs a new MongoDB session store using a collection object.
Params:
collection = the collection to store sessions in.
*/
this(MongoCollection collection)
{
m_sessions = collection;
}

/** The duration without access after which a session expires.
*/
@property Duration expirationTime() const { return m_expirationTime; }
Expand Down

0 comments on commit d7acc12

Please sign in to comment.