Skip to content
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

v4: EXISTS should resolve to number instead of boolean #1819

Closed
OxleyS opened this issue Jan 11, 2022 · 2 comments
Closed

v4: EXISTS should resolve to number instead of boolean #1819

OxleyS opened this issue Jan 11, 2022 · 2 comments
Labels

Comments

@OxleyS
Copy link

OxleyS commented Jan 11, 2022

The raw Redis EXISTS command returns the number of keys, out of the ones passed, that exist in the database. The v4 implementation of client.exists(), however, returns a Promise<boolean>, only returning true if all the passed keys exist.

While I understand making it boolean improves the ergonomics in many cases, this shuts out the possibility of using the command to see if any key of a list exists. (As an aside, it's also a breaking change that should have been mentioned in the migration guide.) It should probably be made to return a number again.

@OxleyS OxleyS added the Bug label Jan 11, 2022
leibale added a commit to leibale/node-redis that referenced this issue Jan 11, 2022
@leibale
Copy link
Collaborator

leibale commented Jan 11, 2022

@OxleyS until we'll release the fix you can use:

const reply = await client.sendCommand(['EXISTS', 'key']);

@akelmj
Copy link

akelmj commented Sep 11, 2022

Not working , return undefined

const reply = await client.sendCommand(['EXISTS', 'category:111']);

and from redisinsight:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants