Skip to content

Node: added sismember command.#1083

Merged
adanWattad merged 1 commit intovalkey-io:mainfrom
adanWattad:node/sismember
Mar 7, 2024
Merged

Node: added sismember command.#1083
adanWattad merged 1 commit intovalkey-io:mainfrom
adanWattad:node/sismember

Conversation

@adanWattad
Copy link
Copy Markdown
Contributor

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@adanWattad adanWattad requested a review from a team as a code owner March 6, 2024 13:33
CHANGELOG.md Outdated
* Node: Allow routing Cluster requests by address. ([#1021](https://github.com/aws/glide-for-redis/pull/1021))
* Python: Added HSETNX command. ([#954](https://github.com/aws/glide-for-redis/pull/954))
* Python: Added SISMEMBER command ([#971](https://github.com/aws/glide-for-redis/pull/971))
* Python, Node: Added SISMEMBER command ([#971](https://github.com/aws/glide-for-redis/pull/971), [#1083](https://github.com/aws/glide-for-redis/pull/1083))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python- it's actually 972

/** Returns if `member` is a member of the set stored at `key`.
* See https://redis.io/commands/sismember/ for more details.
*
* @param key - The key to return the number of its members.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

key - The key of the set.

*
* @param key - The key to return the number of its members.
* @param member - The member to check for existence in the set.
* @returns true if the member exists in the set, false otherwise.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true ... false

* @param key - The key to return the number of its members.
* @param member - The member to check for existence in the set.
* @returns true if the member exists in the set, false otherwise.
* If `key` doesn't exist, it is treated as an empty set and the command returns false.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

false

return this.addAndReturn(createSCard(key));
}

/** Returns if `member` is a member of the set stored at `key`.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

@Yury-Fridlyand Yury-Fridlyand added the node 🐢 Node.js wrapper label Mar 6, 2024
return this.createWritePromise(createSCard(key));
}

/** Returns if `member` is a member of the set stored at `key`.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/** Returns if `member` is a member of the set stored at `key`.
/** Returns whether `member` is a member of the set stored at `key`.

* @param member - The member to check for existence in the set.
* @returns true if the member exists in the set, false otherwise.
* If `key` doesn't exist, it is treated as an empty set and the command returns false.
*/
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if key exists, but it is not a set?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will throw an error, but we decided not to document this error (see other set commands).

await client.sismember(key, "nonExistingMember")
).toEqual(false);
expect(
await client.sismember("nonExistingKey", "member1")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a test when key exists, but it is not a set

@adanWattad adanWattad merged commit 0f7db1a into valkey-io:main Mar 7, 2024
@adanWattad adanWattad deleted the node/sismember branch March 7, 2024 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

node 🐢 Node.js wrapper

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants