# Changelog

*Functional* changes to the public interface of Redis OM for Node.js will be listed here, by version. *Non-functional* changes may also be included, if they are particulary noteworthy or might impact developers using Redis OM.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and Redis OM adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.4.3 - 2023-10-30
### Fixed
- Fixed issue with change of casing in error message in RediSearch when calling `.dropIndex` on *Repository*

### Added
- Add `.expireAt` method to *Repository*
- Add fuzz matching for 'text' type

## 0.4.2 - 2023-07-26
### Fixed
- Fixed issue with TAGs not properl;y escaping question marks

## 0.4.1 - 2023-07-26
### Added
- Added new type of `number[]` which works just like `number` but against an array of them

## 0.4.0 - 2023-07-06
### Added
- Added methods to *Repository* to allow you to provide your own *entityId* instead of relying on a generated one.
- Added support for Redis clustering by passing in a Node Redis connection created with `createCluster`.
- Added better and more meaningful exceptions.

### Changed
- *Schema* now supports nested JSON via the `path` option.
- *Schema* now supports specifying the field for a Hash via the `field` option.
- *Schema* now supports `async` functions for *IdStrategy* allowing you to slow down your saves with I/O calls to generate IDs.
- *Repository* now allows adding Entities with properties that are not in the *Schema*. These can even be nested if you are using JSON.
- *Repository* can be now be constructed directly with `new` in addition to being created from a *Client* via `.fetchRepository`.
- *Repository* can now directly be handed an open Node Redis connection. No need to create a *Client* instance.
- *Client* deprecated in favor of using Node Redis connections.

### Removed
- *Breaking Change* Removed *Entity* class. While still a type, it's no longer a class and is mostly just an alias for a JavaScript object.
- *Breaking Change* Removed `.execute` method on *Client*. Use Node Redis instead.
- *Breaking Change* Removed `.createEntity` and `.createAndSave` methods on *Repository*. Entities are simply JavaScript objects—to create one just create a JavaScript object and call `.save`.
- As *Entity* is no longer a class, custom methods on an *Entity* are no longer supported.

### Fixed
- Corrected parsing where empty arrays were saved to a Hash as an empty String.
- Special characters can now, correctly, be field names


## 0.3.6 - 2022-07-12
### Changed
- *Breaking Change* Removed `.fetchMany` and replaced it with a variadic version of `.fetch`.
- Assorted internal cleanup.
- Changed test suite to use vitest.

## 0.3.5 - 2022-06-21
### Added
- Added additional field attributes to control RediSearch indexing behavior.
- Added search methods to retreive just key name or just *entityIds* instead of the entire entity. Methods include: `.returnAllKeys`, `.returnAllIds`, `.returnFirstKey`, `.returnFirstId`, `.returnPageOfKeys`, `.returnPageOfIds`, `.returnMinKey`, `.returnMinId`, `.returnMaxKey`, `.returnMaxId`
- Added `.fetchMany` to *Repository* which variadicly takes multiple *entityIds* and returns an array of fetch entities.

### Changed
- Search methods that return a single item (like `.first`, `.min`, etc.) and can return *null* are now marked as returning *null* for TypeScript users.
- Repository `.remove` method is now variadic and takes one or more *entityIds* to remove.

## 0.3.4 - 2022-06-07
### Changed
- Added validation for 'point' fields. Throws error when provided invalid longitude or latitude.

### Fixed
- Fixed missing dependency for tslib.


## 0.3.3 - 2022-05-05
### Changed
- Reverted breaking change that changed field `type` from 'string[]' to 'array'. The correct field type is 'string[]'.


## 0.3.2 - 2022-05-03
### Changed
- *Breaking Change*: Date values are stored in EPOCH seconds to align with [date/time APPLY functions](https://redis.io/docs/stack/search/reference/aggregations/#list-of-datetime-apply-functions).

## 0.3.1 - 2022-05-02
### Fixed
- Fixed error when reading `point` containing negative value from HASH.


## 0.3.0 - 2022-04-28
### Changed
- Internal changes in preparation for adding embeddable objects.
- Performance improvements.
- Renamed and reorganized some types that might affect TypeScript users.
- Removed support for Node 12.
- Changed examples in README to assume top-level awaits are available.

### Fixed
- Fixed error in sample code when calling `.use`.


## 0.2.1 - 2022-03-30
### Added
- Added limited ability to sort search results using `.sortBy`.
- Added `.min` and `.max` which returns the *Entity* with the minimum or maximum value for a provided field.

## 0.2.0 - 2022-02-25
### Added
- Added 'point' data type that represents a spot on the globe.
- Added 'date' data type with UNIX, ISO-8601, and JavaScript flavors.
- Perform radius searches on 'point' data type using `.inRadius`.
- Perform searches on 'date' data type using `.before`, `.after`, etc.
- Issue raw RediSearch commands using `Repository.searchRaw`.
- Attach existing Node Redis connections using `.use` on *Client*. Handy if you need to do raw Redis stuff too!
- Added `.keyName` property on *Entity* that lets you to get the Redis keyname storing that *Entity*.
- Added `.expire` method to *Repository* allowing you to expire an *Entity*.

### Changed
- String fields and searches can now be set to numbers or booleans and will be coerced to a string.
- Calls to `.createIndex` will automatically reindex if the index has changed and will do nothing if the index has not changed.
- *Breaking Change*: Changed 'array' type in Schema definitions to 'string[]' in preparation for adding other types of arrays.
- *Breaking Change*: Split 'string' type into 'string' and 'text' types, representing string values that support `.eq` searches and text values that support `.match` searches.
- *Breaking Change*: Removed the `textSearch` property from strings as it was no longer needed with 'string' and 'text' types replacing it.
- *Breaking Change*: *Schema* data structure now defaults to JSON instead of HASH.

### Fixed
- Wildcard searches on text fields no longer fail.
- Tag searches now escape slash and backslash characters.

### Removed
- *Breaking Change*: `Repository` constructor cannot be directly called. Use `client.fetchRepository` instead.


## 0.1.7 - 2022-01-07
### Added
- Added `.isOpen` to *Client*

### Changed
- *Client* no longer errors when opened or closed if already opened or closed.
- Update table of contents in README.


## 0.1.6 - 2022-01-05
### Added
- Added `.return.first` and `.returnFirst` methods to search. Sometimes you really can eat just one.

### Fixed
- *Entity* now has a better default JSON serialization output.


## 0.1.5 - 2021-12-23
### Added
- Added ability to pass in initial values when creating an *Entity* with `.createEntity`.
- Added `.createAndSave` method to Repository that does exactly what you think it does.

### Changed
- More fluent interface on `.return.all`, `return.page`, and `return.count` on *Search*.
- Replace `.return` with `.returnPage` in *Search* class.


## 0.1.4 - 2021-12-17
### Added
- This CHANGELOG file because communicating changes matters.
- Ability to specify and override default stop word behavior when defining a *Schema*.

### Fixed
- Doing an exact match with a stop word used to generate a cryptic error. RediSearch does not permit searching for stop words within an exact match. This error was captured, and a better error is presented that directs the user to either change their stop words or not use stop words in their query.
