JLuboff / connect-mssql-v2

MS SQL Server session store for Express Session
MIT License
5 stars 7 forks source link

Switched "all" methods return from sessionData[] to { [sid: string]: sessionData } #28

Closed master117 closed 3 years ago

master117 commented 3 years ago

What: Switched "all" methods return from sessionData[] to { [sid: string]: sessionData }, so it is possible to retrieve the sid of all sessions. Adjusted documentation.

Why: I wanted to use the all method to find all sessions and then destroy all sessions for certain users / tokens. Without the sid it's not possible to destroy certain sessions. And my first implementation for the all method would not include sids.

Why not: { sid: string, data: sessionData }[] I actually would have prefered to return{ sid: string, data: sessionData }[] to easily link sid and session data but when looking at express-session index.d.ts I only found:

all: (callback: (err: any, obj?: { [sid: string]: Express.SessionData; } | null) => void) => void;

master117 commented 3 years ago

I tried adjusting tests, but I'm not sure what is the best way to test this, since sids are randomized.

JLuboff commented 3 years ago

I'll give this a review tomorrow. Thank you!

master117 commented 3 years ago

Can you parse the results into your return object

Of course, my bad.

Tests adjusted as well.

JLuboff commented 3 years ago

Merged! I'll get it onto NPM shortly