simplesessions icon indicating copy to clipboard operation
simplesessions copied to clipboard

[Feature request] Chain Setting values in session

Open joicemjoseph opened this issue 3 years ago • 5 comments

It will be great to have a feature to set values to a session, like the following.

sess, _ := session.Aquire(...,...)
err := sess.Set('key1', 'value1').Set('key2', 'value2')...Commit()

If this sounds good, I can add this feature.

joicemjoseph avatar Jun 08 '21 02:06 joicemjoseph

Do you mean a chainable shorthand instead of the current:

sess, _ := session.Aquire(...,...)
sess.Set('key1', 'value1')
sess.Set('key2', 'value2')
sess.Commit()

knadh avatar Jun 08 '21 06:06 knadh

Do you mean a chainable shorthand instead of the current:

Yes.

joicemjoseph avatar Jun 08 '21 07:06 joicemjoseph

Yep, makes sense to have. Obviously, can't break the Set() API, so we can introduce a SetM().SetM()... (M = many / multi). @vividvilla ?

knadh avatar Jun 08 '21 07:06 knadh

This lib doesn't use chain pattern so the ideal API would be SetMulti(arg1, val1, ...). @joicemjoseph If you are interested then send a PR.

Edit: we already have GetMulti(arg...) so this conforms to current API.

vividvilla avatar Jun 08 '21 08:06 vividvilla

I will raise a PR.

joicemjoseph avatar Jun 08 '21 08:06 joicemjoseph