Persist mongodb session

I'm using mongoose as ODM for my nodejs application Can I persist started mongodb session to storage like redis, for get and continue it later? For something like this cases -

  1. User make request with some data
  2. On server we are starting new session, starting transaction on this session and make some changes on database
  3. Get an error on server, but does not abort transaction/end session
  4. Response user with error and session id
  5. User make some changes on request and send corrected data to server with session id
  6. Instantiate session from id on server, and we do not start the operation from the beginning, but using the instantiated session and continue from the place where we stopped last time

Mongoose is using node-mongodb-driver. On it documentation and sources they notice, that clientsession not meant to be instantiated directly.

Can I get around this limitation, or it is bad pratice to use one session through many users requests?


Ответы (0 шт):