redis / redis-om-node

Object mapping, and more, for Redis and Node.js. Written in TypeScript.
MIT License
1.14k stars 77 forks source link

Requesting for feature like repository.exist(key) #235

Open DhruvinDaveTis opened 1 month ago

DhruvinDaveTis commented 1 month ago

I am proposing a new feature for the GitHub Redis-om library, aiming to enhance its capabilities with a repository pattern for fluent chaining methods akin to Laravel's Eloquent. This feature aims to streamline data retrieval from Redis by introducing a repository method for finding data with a fluent chaining syntax, facilitating cleaner and more expressive code. Additionally, I suggest the inclusion of a new method, repository.exist(key), designed to efficiently check the existence of a key within Redis. This method would provide a simple yet powerful means to ascertain whether a specific key exists in the Redis database, aiding in data validation and workflow logic. By integrating these enhancements, the library would offer developers a more intuitive and efficient approach to working with Redis data, aligning with modern development patterns and best practices.

guyroyse commented 1 month ago

I'm down for a PR that adds this method to the repository. A couple of things that I will require:

  1. Please call it .exists as that matches the Node Redis function that does the same thing.
  2. It needs to take EntityIds and not keys. Everything in the Repository works that way. Needs to be consistent.
  3. Model it after the .remove command which takes a single EntityId, multiple EntityIds, or an array of EntityIds.
  4. Be sure to add the comments that generate the docs.

Great idea!