Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Express session MongoDB store: connect-mongo vs connect-mongodb-session

By now (10.7.2016) express-session's github-page suggests two mongodb session stores:

  1. connect-mongo | A MongoDB-based session store - Github (775 Stars)
  2. connect-mongodb-session | Lightweight MongoDB-based session store built and maintained by MongoDB - Github (6 Stars)

Which one should i choose and what are the differences between the two of them? By popularity clearly connect-mongo wins, but is it really the "better" product? Why did MongoDB itself bother to programm connect-mongodb-session with an existing solution?

Any advice appriciated.

P.S.: I noted that there are several (outdated) SO questions comparing different MongoDB backed session stored but (as far as i notices) non compared these recommended two.

like image 233
Rentrop Avatar asked Jul 10 '15 09:07

Rentrop


1 Answers

Connect-mongo has been around for much longer, while connect-mongodb-session was designed to be easier to use by being more opinionated. Connect-mongo has many more options to tweak.

The maintainers of the two libraries have a good discussion of their differences at https://github.com/mongodb-js/connect-mongodb-session/issues/15. The tl;dr is that both are stable. The only major design difference is that connect-mongodb-session does not believe that session queries should share the connection pool with other clients of the db, while connect-mongo believes they should. Both maintainers present good arguments.

Despite their apparent stability, both have surprisingly high numbers of commits. A closer look shows that most of the commits to connect-mongodb-session have just been an ongoing race to keep the dependency pointing to the latest versions of the drivers.

like image 194
David Goldfarb Avatar answered Sep 29 '22 13:09

David Goldfarb