kleydon / prisma-session-store

Express session store for Prisma
MIT License
116 stars 18 forks source link

fix: remove immutable id field from query for MongoDB #96

Closed SunburntRock89 closed 1 year ago

SunburntRock89 commented 1 year ago

This fixes issue #83 and should provide proper MongoDB support.

SunburntRock89 commented 1 year ago

This breaks the current tests which expect an ID field to be present at all times, will try fix

SunburntRock89 commented 1 year ago

This does have me ask the question of what the difference between id and sid is. id is the primary key but sid seems to be used to reference the object in most places I've looked.

Also: Feel free to tell me I'm doing stuff wrong here, I've never actually made a proper PR before :)

kleydon commented 1 year ago

Appreciate the contribution, @SunburntRock89 !

This does have me ask the question of what the difference between id and sid is. id is the primary key but sid seems to be used to reference the object in most places I've looked.

The idea was to not require the session id to be the same as the database record id... I'm not 100% sure that we had a great reason for retaining this flexibility, but maybe there are situations where you might want it. (Maybe all of your db records have integer ids, but you want your session ids to be prefixed with se- when debugging in javascript or something like that...)

I think this PR not only enables/fixes support for MongoDB, but also makes the library more bulletproof, as its now less possible (I think?) for sid and id to ever get out of sync (i.e. situations where they aren't the same, AND dbRecordIdFunction() fails to accurately produce id given sid).

Thanks again!

kleydon commented 1 year ago

:tada: This PR is included in version 3.1.7 :tada:

The release is available on:

Your semantic-release bot :package::rocket: