jdesboeufs / connect-mongo

MongoDB session store for Express

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow to access the request object for e.g., setting the dbName dynamically and based on the request

lkj4 opened this issue · comments

commented
  • I'm submitting a ...
    [ ] bug report
    [x] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary

I want to access the request object in order to set dynamically and based on the request the to be used dbName. I could wrap session(...) into req => ... and then access req but then I can't call express' next anymore and the request gets stuck.

Pls let me know if you need further info.

commented

Ok, I've learned that I can't add middleware dynamically[1], or this is what I've been actually trying. The question now is if your lib could offer the option to set dbName also with a function which then, can give access to the request option, such as:

  ...
  dbName: req => req.hostname,
  ...

Why do you need to use different db depends on req? What is your use case? Can it be a field inside the session instead? I don't think dynamic dbName base on req is a good idea.

commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.