-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(free): add readKeys method to free session storage adapter #242
base: main
Are you sure you want to change the base?
Conversation
Adding the readKeys Method to the Free Session Storage Adapter -Problem Right now, we have a read method that lets you read a session, but it requires a key. The question is... how do you get that key? Well, I have no idea. -Solution The new readKeys method helps you fetch all available keys, which you can then use with read to get specific session data. -Changes Due to readKeys - key in call is now optional, allowing global calls. - The URL structure now depends on key: - If key is provided, you want to read a specific session (like read does now). - If key is missing, you want to retrieve all session keys (which readKeys now handles). -Notes The endpoint /sessions used for readKeys is provided by the free storage adapter server here: https://github.com/grammyjs/free-session-backend/blob/778a383057e7b8a244fdb2beee20542d8ce0867b/src/main.ts#L89 PS: Hope this helps someone in the future, just like it helped me today! Hihihi
…sion keys Co-authored-by: KnorpelSenf <[email protected]>
…lready implemented Co-authored-by: KnorpelSenf <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff! Thanks! Let's wait for another review by @Satont who maintains the storage adapters before merging this
ok well ;) |
I think that here also a readSessions method could be implemented, to directly provide all available sessions. I currently need to retrieve all my sessions and migrate to mongodb. by looping the read method with the keys it is possible but it would be more efficient if a readSessions was implemented. |
Adding the
readAllKeys
Method to the Free Session Storage AdapterProblem
Right now, we have a
read
method that lets you read a session, but it requires akey
. The question is... how do you get thatkey
? Well, I don't know ;)Solution
The new
readAllKeys
method helps you fetch all available keys, which you can then use withread
to get specific session data.Changes Due to
readAllKeys
key
incall
is now optional, allowing global requests.key
:key
is provided, you want to read a specific session (likeread
does now).key
is missing, you want to retrieve all session keys (whichreadAllKeys
now handles).Notes
The endpoint
/sessions
used forreadAllKeys
is provided by the storage adapter server here:https://github.com/grammyjs/free-session-backend/blob/778a383057e7b8a244fdb2beee20542d8ce0867b/src/main.ts#L89
PS: Hope this helps someone in the future, just like it helped me today! Hihihi