diff --git a/CHANGELOG b/CHANGELOG index 41fa8d43..f7c80a1a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,21 +4,35 @@ 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.0 - 2022-12-08 +### Added +- Added methods to *Repository* to allow you to provide your own *entityId* instead of relying on a generated one. + +### Changed +- *Breaking Change* Removed *Entity* class. While still a type, it's no longer a class and is just an alias for a JavaScript object. +- *Schema* now supports nested JSON via the `path` option. +- *Schema* now supports specifying the field for a Hash via the `field` option. +- *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`. + +### Removed +- As *Entity* is no longer a class, custom methods on an *Entity* are no longer supported. + ## 0.3.6 - 2022-07-12 ### Changed -- *Breaking Change* Removed .fetchMany and replaced it with a variadic version of .fetch. +- *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 entity IDs 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 entity IDs and returns an array of fetch entities. +- 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 entity IDs to remove. +- 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 @@ -30,13 +44,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## 0.3.3 - 2022-05-05 ### Changed -- Reverted breaking change that changed field type from 'string[]' to 'array'. The correct field type is 'string[]'. +- 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) - +- *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 @@ -58,7 +71,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## 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. +- 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 @@ -67,9 +80,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - 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 `Client.use`. 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`. +- 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. @@ -77,7 +90,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - *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. +- *Breaking Change*: *Schema* data structure now defaults to JSON instead of HASH. ### Fixed - Wildcard searches on text fields no longer fail. @@ -89,35 +102,35 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## 0.1.7 - 2022-01-07 ### Added -- Added .isOpen() to Client +- Added `.isOpen` to *Client* ### Changed -- Client no longer errors when opened or closed if already opened or closed. +- *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. +- 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. +- *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. +- 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. +- 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. +- 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. diff --git a/docs/.nojekyll b/docs/.nojekyll new file mode 100644 index 00000000..e2ac6616 --- /dev/null +++ b/docs/.nojekyll @@ -0,0 +1 @@ +TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false. \ No newline at end of file diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 00000000..16ebe6ba --- /dev/null +++ b/docs/README.md @@ -0,0 +1,403 @@ +redis-om + +# redis-om + +## Table of contents + +### Classes + +- [AbstractSearch](classes/AbstractSearch.md) +- [Circle](classes/Circle.md) +- [Client](classes/Client.md) +- [Field](classes/Field.md) +- [RawSearch](classes/RawSearch.md) +- [RedisError](classes/RedisError.md) +- [Repository](classes/Repository.md) +- [Schema](classes/Schema.md) +- [Search](classes/Search.md) +- [Where](classes/Where.md) +- [WhereField](classes/WhereField.md) + +### Type Aliases + +- [AllFieldDefinition](README.md#allfielddefinition) +- [BooleanFieldDefinition](README.md#booleanfielddefinition) +- [CircleFunction](README.md#circlefunction) +- [CommonFieldDefinition](README.md#commonfielddefinition) +- [DataStructure](README.md#datastructure) +- [DateFieldDefinition](README.md#datefielddefinition) +- [Entity](README.md#entity) +- [EntityData](README.md#entitydata) +- [EntityId](README.md#entityid) +- [FieldDefinition](README.md#fielddefinition) +- [FieldType](README.md#fieldtype) +- [IdStrategy](README.md#idstrategy) +- [NumberFieldDefinition](README.md#numberfielddefinition) +- [Point](README.md#point) +- [PointFieldDefinition](README.md#pointfielddefinition) +- [RedisConnection](README.md#redisconnection) +- [SchemaDefinition](README.md#schemadefinition) +- [SchemaOptions](README.md#schemaoptions) +- [StopWordOptions](README.md#stopwordoptions) +- [StringArrayFieldDefinition](README.md#stringarrayfielddefinition) +- [StringFieldDefinition](README.md#stringfielddefinition) +- [SubSearchFunction](README.md#subsearchfunction) +- [TextFieldDefinition](README.md#textfielddefinition) + +## Type Aliases + +### AllFieldDefinition + +Ƭ **AllFieldDefinition**: `Object` + +All configuration properties that any field might have, regardless of type. + +#### Type declaration + +| Name | Type | Description | +| :------ | :------ | :------ | +| `alias?` | `string` | The default field name in Redis is the property name defined in the [SchemaDefinition](README.md#schemadefinition). Overrides the field name for a Hash to this value or in the case of JSON documents, sets the JSONPath to this value preceded by `$.`. Overridden by [field](README.md#field) and/or [path](README.md#path) settings. | +| `caseSensitive?` | `boolean` | Is the original case of this field indexed with Redis OM. Defaults to false. | +| `field?` | `string` | The field name used to store this in a Redis Hash. Defaults to the name used in the [SchemaDefinition](README.md#schemadefinition) or the [alias](README.md#alias) property. | +| `indexed?` | `boolean` | Is this field indexed and thus searchable with Redis OM. Defaults to true. | +| `matcher?` | ``"dm:en"`` \| ``"dm:fr"`` \| ``"dm:pt"`` \| ``"dm:es"`` | Enables setting the phonetic matcher to use, supported matchers are: dm:en - Double Metaphone for English dm:fr - Double Metaphone for French dm:pt - Double Metaphone for Portuguese dm:es - Double Metaphone for Spanish | +| `normalized?` | `boolean` | Is this (sortable) field normalized when indexed. Defaults to true. | +| `path?` | `string` | The JSONPath expression this field references. Used only by search and only for JSON documents. Defaults to the name used in the [SchemaDefinition](README.md#schemadefinition) or the [alias](README.md#alias) property prefixed with `$.` . | +| `separator?` | `string` | Due to how RediSearch works, strings and arrays are sometimes stored the same in Redis, as a simple string. This is the separator used to split those strings when it is an array. If your StringField contains this separator, this can cause problems. You can change it here to avoid those problems. Defaults to `\|`. | +| `sortable?` | `boolean` | Enables sorting by this field. | +| `stemming?` | `boolean` | Is word stemming applied to this field with Redis OM. Defaults to true. | +| `type` | [`FieldType`](README.md#fieldtype) | The type of the field (i.e. string, number, boolean, etc.) | +| `weight?` | `number` | Enables setting the weight to apply to a text field | + +#### Defined in + +[lib/schema/definitions.ts:5](https://github.com/redis/redis-om-node/blob/61aae69/lib/schema/definitions.ts#L5) + +___ + +### BooleanFieldDefinition + +Ƭ **BooleanFieldDefinition**: { `type`: ``"boolean"`` } & [`CommonFieldDefinition`](README.md#commonfielddefinition) & `Pick`<[`AllFieldDefinition`](README.md#allfielddefinition), ``"sortable"``\> + +A field representing a boolean. + +#### Defined in + +[lib/schema/definitions.ts:77](https://github.com/redis/redis-om-node/blob/61aae69/lib/schema/definitions.ts#L77) + +___ + +### CircleFunction + +Ƭ **CircleFunction**: (`circle`: [`Circle`](classes/Circle.md)) => [`Circle`](classes/Circle.md) + +#### Type declaration + +▸ (`circle`): [`Circle`](classes/Circle.md) + +A function that defines a circle for `.inCircle` searches. + +##### Parameters + +| Name | Type | +| :------ | :------ | +| `circle` | [`Circle`](classes/Circle.md) | + +##### Returns + +[`Circle`](classes/Circle.md) + +#### Defined in + +[lib/search/where-point.ts:8](https://github.com/redis/redis-om-node/blob/61aae69/lib/search/where-point.ts#L8) + +___ + +### CommonFieldDefinition + +Ƭ **CommonFieldDefinition**: `Pick`<[`AllFieldDefinition`](README.md#allfielddefinition), ``"type"`` \| ``"alias"`` \| ``"indexed"`` \| ``"field"`` \| ``"path"``\> + +The configuration properties that all fields have in common. + +#### Defined in + +[lib/schema/definitions.ts:74](https://github.com/redis/redis-om-node/blob/61aae69/lib/schema/definitions.ts#L74) + +___ + +### DataStructure + +Ƭ **DataStructure**: ``"HASH"`` \| ``"JSON"`` + +The type of data structure in Redis to map objects to. + +#### Defined in + +[lib/schema/options.ts:2](https://github.com/redis/redis-om-node/blob/61aae69/lib/schema/options.ts#L2) + +___ + +### DateFieldDefinition + +Ƭ **DateFieldDefinition**: { `type`: ``"date"`` } & [`CommonFieldDefinition`](README.md#commonfielddefinition) & `Pick`<[`AllFieldDefinition`](README.md#allfielddefinition), ``"sortable"``\> + +A field representing a date/time. + +#### Defined in + +[lib/schema/definitions.ts:82](https://github.com/redis/redis-om-node/blob/61aae69/lib/schema/definitions.ts#L82) + +___ + +### Entity + +Ƭ **Entity**: [`EntityId`](README.md#entityid) & [`EntityData`](README.md#entitydata) + +Defines the objects returned from calls to [repositories](classes/Repository.md). + +#### Defined in + +[lib/entity/entity.ts:2](https://github.com/redis/redis-om-node/blob/61aae69/lib/entity/entity.ts#L2) + +___ + +### EntityData + +Ƭ **EntityData**: `Object` + +The free-form data associated with an [Entity](README.md#entity). + +#### Index signature + +▪ [key: `string`]: `any` + +#### Defined in + +[lib/entity/entity.ts:13](https://github.com/redis/redis-om-node/blob/61aae69/lib/entity/entity.ts#L13) + +___ + +### EntityId + +Ƭ **EntityId**: `Object` + +Specific data that uniquely identifies an [Entity](README.md#entity). + +#### Type declaration + +| Name | Type | Description | +| :------ | :------ | :------ | +| `entityId?` | `string` | The unique ID of the [Entity](README.md#entity). | +| `keyName?` | `string` | The key the [Entity](README.md#entity) is stored under inside of Redis. | + +#### Defined in + +[lib/entity/entity.ts:5](https://github.com/redis/redis-om-node/blob/61aae69/lib/entity/entity.ts#L5) + +___ + +### FieldDefinition + +Ƭ **FieldDefinition**: [`BooleanFieldDefinition`](README.md#booleanfielddefinition) \| [`DateFieldDefinition`](README.md#datefielddefinition) \| [`NumberFieldDefinition`](README.md#numberfielddefinition) \| [`PointFieldDefinition`](README.md#pointfielddefinition) \| [`StringArrayFieldDefinition`](README.md#stringarrayfielddefinition) \| [`StringFieldDefinition`](README.md#stringfielddefinition) \| [`TextFieldDefinition`](README.md#textfielddefinition) + +Contains instructions telling how to map a property on an [Entity](README.md#entity) to Redis. + +#### Defined in + +[lib/schema/definitions.ts:111](https://github.com/redis/redis-om-node/blob/61aae69/lib/schema/definitions.ts#L111) + +___ + +### FieldType + +Ƭ **FieldType**: ``"boolean"`` \| ``"date"`` \| ``"number"`` \| ``"point"`` \| ``"string"`` \| ``"string[]"`` \| ``"text"`` + +Valid field types for a [FieldDefinition](README.md#fielddefinition). + +#### Defined in + +[lib/schema/definitions.ts:2](https://github.com/redis/redis-om-node/blob/61aae69/lib/schema/definitions.ts#L2) + +___ + +### IdStrategy + +Ƭ **IdStrategy**: () => `string` + +#### Type declaration + +▸ (): `string` + +A function that generates random entityIds. + +##### Returns + +`string` + +#### Defined in + +[lib/schema/options.ts:5](https://github.com/redis/redis-om-node/blob/61aae69/lib/schema/options.ts#L5) + +___ + +### NumberFieldDefinition + +Ƭ **NumberFieldDefinition**: { `type`: ``"number"`` } & [`CommonFieldDefinition`](README.md#commonfielddefinition) & `Pick`<[`AllFieldDefinition`](README.md#allfielddefinition), ``"sortable"``\> + +A field representing a number. + +#### Defined in + +[lib/schema/definitions.ts:87](https://github.com/redis/redis-om-node/blob/61aae69/lib/schema/definitions.ts#L87) + +___ + +### Point + +Ƭ **Point**: `Object` + +Defines a point on the globe using longitude and latitude. + +#### Type declaration + +| Name | Type | Description | +| :------ | :------ | :------ | +| `latitude` | `number` | The latitude of the point. | +| `longitude` | `number` | The longitude of the point. | + +#### Defined in + +[lib/entity/entity.ts:18](https://github.com/redis/redis-om-node/blob/61aae69/lib/entity/entity.ts#L18) + +___ + +### PointFieldDefinition + +Ƭ **PointFieldDefinition**: { `type`: ``"point"`` } & [`CommonFieldDefinition`](README.md#commonfielddefinition) + +A field representing a point on the globe. + +#### Defined in + +[lib/schema/definitions.ts:92](https://github.com/redis/redis-om-node/blob/61aae69/lib/schema/definitions.ts#L92) + +___ + +### RedisConnection + +Ƭ **RedisConnection**: `ReturnType` + +A Redis connection. + +#### Defined in + +[lib/client/client.ts:8](https://github.com/redis/redis-om-node/blob/61aae69/lib/client/client.ts#L8) + +___ + +### SchemaDefinition + +Ƭ **SchemaDefinition**: `Record`<`string`, [`FieldDefinition`](README.md#fielddefinition)\> + +Group of [FieldDefinition](README.md#fielddefinition)s that define the schema for an [Entity](README.md#entity). + +#### Defined in + +[lib/schema/definitions.ts:117](https://github.com/redis/redis-om-node/blob/61aae69/lib/schema/definitions.ts#L117) + +___ + +### SchemaOptions + +Ƭ **SchemaOptions**: `Object` + +Configuration options for a [Schema](classes/Schema.md). + +#### Type declaration + +| Name | Type | Description | +| :------ | :------ | :------ | +| `dataStructure?` | [`DataStructure`](README.md#datastructure) | The data structure used to store the [Entity](README.md#entity) in Redis. Can be set to either `JSON` or `HASH`. Defaults to JSON. | +| `idStrategy?` | [`IdStrategy`](README.md#idstrategy) | A function that generates a random entityId. Defaults to a function that generates [ULIDs](https://github.com/ulid/spec). Combined with prefix to generate a Redis key. If prefix is `Foo` and idStratgey returns `12345` then the generated key would be `Foo:12345`. | +| `indexHashName?` | `string` | The name used by Redis OM to store the hash of the index for this [Schema](classes/Schema.md). Defaults to prefix followed by `:index:hash`. So, for a prefix of `Foo`, it would use `Foo:index:hash`. | +| `indexName?` | `string` | The name used by RediSearch to store the index for this [Schema](classes/Schema.md). Defaults to prefix followed by `:index`. So, for a prefix of `Foo`, it would use `Foo:index`. | +| `stopWords?` | `string`[] | Stop words to be used by this schema. If `useStopWords` is anything other than `CUSTOM`, this option is ignored. | +| `useStopWords?` | [`StopWordOptions`](README.md#stopwordoptions) | Configures the usage of stop words. Valid values are `OFF`, `DEFAULT`, and `CUSTOM`. Setting this to `OFF` disables all stop words. Setting this to `DEFAULT` uses the stop words intrinsic to RediSearch. Setting this to `CUSTOM` tells RediSearch to use the stop words in `stopWords`. | + +#### Defined in + +[lib/schema/options.ts:11](https://github.com/redis/redis-om-node/blob/61aae69/lib/schema/options.ts#L11) + +___ + +### StopWordOptions + +Ƭ **StopWordOptions**: ``"OFF"`` \| ``"DEFAULT"`` \| ``"CUSTOM"`` + +Valid values for how to use stop words for a given [Schema](classes/Schema.md). + +#### Defined in + +[lib/schema/options.ts:8](https://github.com/redis/redis-om-node/blob/61aae69/lib/schema/options.ts#L8) + +___ + +### StringArrayFieldDefinition + +Ƭ **StringArrayFieldDefinition**: { `type`: ``"string[]"`` } & [`CommonFieldDefinition`](README.md#commonfielddefinition) & `Pick`<[`AllFieldDefinition`](README.md#allfielddefinition), ``"sortable"`` \| ``"caseSensitive"`` \| ``"normalized"`` \| ``"separator"``\> + +A field representing an array of strings. + +#### Defined in + +[lib/schema/definitions.ts:96](https://github.com/redis/redis-om-node/blob/61aae69/lib/schema/definitions.ts#L96) + +___ + +### StringFieldDefinition + +Ƭ **StringFieldDefinition**: { `type`: ``"string"`` } & [`CommonFieldDefinition`](README.md#commonfielddefinition) & `Pick`<[`AllFieldDefinition`](README.md#allfielddefinition), ``"sortable"`` \| ``"caseSensitive"`` \| ``"normalized"`` \| ``"separator"``\> + +A field representing a whole string. + +#### Defined in + +[lib/schema/definitions.ts:101](https://github.com/redis/redis-om-node/blob/61aae69/lib/schema/definitions.ts#L101) + +___ + +### SubSearchFunction + +Ƭ **SubSearchFunction**: (`search`: [`Search`](classes/Search.md)) => [`Search`](classes/Search.md) + +#### Type declaration + +▸ (`search`): [`Search`](classes/Search.md) + +A function that takes a [Search](classes/Search.md) and returns a [Search](classes/Search.md). Used in nested queries. + +##### Parameters + +| Name | Type | +| :------ | :------ | +| `search` | [`Search`](classes/Search.md) | + +##### Returns + +[`Search`](classes/Search.md) + +#### Defined in + +[lib/search/search.ts:25](https://github.com/redis/redis-om-node/blob/61aae69/lib/search/search.ts#L25) + +___ + +### TextFieldDefinition + +Ƭ **TextFieldDefinition**: { `type`: ``"text"`` } & [`CommonFieldDefinition`](README.md#commonfielddefinition) & `Pick`<[`AllFieldDefinition`](README.md#allfielddefinition), ``"sortable"`` \| ``"normalized"`` \| ``"matcher"`` \| ``"stemming"`` \| ``"weight"``\> + +A field representing searchable text. + +#### Defined in + +[lib/schema/definitions.ts:106](https://github.com/redis/redis-om-node/blob/61aae69/lib/schema/definitions.ts#L106) diff --git a/docs/classes/AbstractSearch.md b/docs/classes/AbstractSearch.md new file mode 100644 index 00000000..6cf0c0b6 --- /dev/null +++ b/docs/classes/AbstractSearch.md @@ -0,0 +1,758 @@ +[redis-om](../README.md) / AbstractSearch + +# Class: AbstractSearch + +Abstract base class for [Search](Search.md) and [RawSearch](RawSearch.md) that +contains methods to return search results. + +**`template`** The type of [Entity](../README.md#entity) being sought. + +## Hierarchy + +- **`AbstractSearch`** + + ↳ [`RawSearch`](RawSearch.md) + + ↳ [`Search`](Search.md) + +## Table of contents + +### Accessors + +- [return](AbstractSearch.md#return) + +### Methods + +- [all](AbstractSearch.md#all) +- [allIds](AbstractSearch.md#allids) +- [allKeys](AbstractSearch.md#allkeys) +- [count](AbstractSearch.md#count) +- [first](AbstractSearch.md#first) +- [firstId](AbstractSearch.md#firstid) +- [firstKey](AbstractSearch.md#firstkey) +- [max](AbstractSearch.md#max) +- [maxId](AbstractSearch.md#maxid) +- [maxKey](AbstractSearch.md#maxkey) +- [min](AbstractSearch.md#min) +- [minId](AbstractSearch.md#minid) +- [minKey](AbstractSearch.md#minkey) +- [page](AbstractSearch.md#page) +- [pageOfIds](AbstractSearch.md#pageofids) +- [pageOfKeys](AbstractSearch.md#pageofkeys) +- [returnAll](AbstractSearch.md#returnall) +- [returnAllIds](AbstractSearch.md#returnallids) +- [returnAllKeys](AbstractSearch.md#returnallkeys) +- [returnCount](AbstractSearch.md#returncount) +- [returnFirst](AbstractSearch.md#returnfirst) +- [returnFirstId](AbstractSearch.md#returnfirstid) +- [returnFirstKey](AbstractSearch.md#returnfirstkey) +- [returnMax](AbstractSearch.md#returnmax) +- [returnMaxId](AbstractSearch.md#returnmaxid) +- [returnMaxKey](AbstractSearch.md#returnmaxkey) +- [returnMin](AbstractSearch.md#returnmin) +- [returnMinId](AbstractSearch.md#returnminid) +- [returnMinKey](AbstractSearch.md#returnminkey) +- [returnPage](AbstractSearch.md#returnpage) +- [returnPageOfIds](AbstractSearch.md#returnpageofids) +- [returnPageOfKeys](AbstractSearch.md#returnpageofkeys) +- [sortAsc](AbstractSearch.md#sortasc) +- [sortAscending](AbstractSearch.md#sortascending) +- [sortBy](AbstractSearch.md#sortby) +- [sortDesc](AbstractSearch.md#sortdesc) +- [sortDescending](AbstractSearch.md#sortdescending) + +## Accessors + +### return + +• `get` **return**(): [`AbstractSearch`](AbstractSearch.md) + +Returns the current instance. Syntactic sugar to make your code more fluent. + +#### Returns + +[`AbstractSearch`](AbstractSearch.md) + +this + +## Methods + +### all + +▸ **all**(`options?`): `Promise`<[`Entity`](../README.md#entity)[]\> + +Returns all the [Entities](../README.md#entity) that match this query. This method +makes multiple calls to Redis until all the [Entities](../README.md#entity) are returned. +You can specify the batch size by setting the `pageSize` property on the +options: + +```typescript +const entities = await repository.search().returnAll({ pageSize: 100 }) +``` + +#### Parameters + +| Name | Type | Default value | Description | +| :------ | :------ | :------ | :------ | +| `options` | `Object` | `undefined` | Options for the call. | +| `options.pageSize` | `number` | `10` | Number of [Entities](../README.md#entity) returned per batch. | + +#### Returns + +`Promise`<[`Entity`](../README.md#entity)[]\> + +An array of [Entities](../README.md#entity) matching the query. + +___ + +### allIds + +▸ **allIds**(`options?`): `Promise`<`string`[]\> + +Returns all the entity IDs that match this query. This method +makes multiple calls to Redis until all the entity IDs are returned. +You can specify the batch size by setting the `pageSize` property on the +options: + +```typescript +const keys = await repository.search().returnAllIds({ pageSize: 100 }) +``` + +#### Parameters + +| Name | Type | Default value | Description | +| :------ | :------ | :------ | :------ | +| `options` | `Object` | `undefined` | Options for the call. | +| `options.pageSize` | `number` | `10` | Number of entity IDs returned per batch. | + +#### Returns + +`Promise`<`string`[]\> + +An array of entity IDs matching the query. + +___ + +### allKeys + +▸ **allKeys**(`options?`): `Promise`<`string`[]\> + +Returns all the key names in Redis that match this query. This method +makes multiple calls to Redis until all the key names are returned. +You can specify the batch size by setting the `pageSize` property on the +options: + +```typescript +const keys = await repository.search().returnAllKeys({ pageSize: 100 }) +``` + +#### Parameters + +| Name | Type | Default value | Description | +| :------ | :------ | :------ | :------ | +| `options` | `Object` | `undefined` | Options for the call. | +| `options.pageSize` | `number` | `10` | Number of key names returned per batch. | + +#### Returns + +`Promise`<`string`[]\> + +An array of key names matching the query. + +___ + +### count + +▸ **count**(): `Promise`<`number`\> + +Returns the number of [Entities](../README.md#entity) that match this query. + +#### Returns + +`Promise`<`number`\> + +___ + +### first + +▸ **first**(): `Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +Returns the first [Entity](../README.md#entity) that matches this query. + +#### Returns + +`Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +___ + +### firstId + +▸ **firstId**(): `Promise`<``null`` \| `string`\> + +Returns the first entity ID that matches this query. + +#### Returns + +`Promise`<``null`` \| `string`\> + +___ + +### firstKey + +▸ **firstKey**(): `Promise`<``null`` \| `string`\> + +Returns the first key name that matches this query. + +#### Returns + +`Promise`<``null`` \| `string`\> + +___ + +### max + +▸ **max**(`field`): `Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +Finds the [Entity](../README.md#entity) with the maximal value for a field. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `field` | `string` | The field with the maximal value. | + +#### Returns + +`Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +The entity ID [Entity](../README.md#entity) with the maximal value + +___ + +### maxId + +▸ **maxId**(`field`): `Promise`<``null`` \| `string`\> + +Finds the entity ID with the maximal value for a field. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `field` | `string` | The field with the maximal value. | + +#### Returns + +`Promise`<``null`` \| `string`\> + +The entity ID with the maximal value + +___ + +### maxKey + +▸ **maxKey**(`field`): `Promise`<``null`` \| `string`\> + +Finds the key name in Redis with the maximal value for a field. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `field` | `string` | The field with the maximal value. | + +#### Returns + +`Promise`<``null`` \| `string`\> + +The key name with the maximal value + +___ + +### min + +▸ **min**(`field`): `Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +Finds the [Entity](../README.md#entity) with the minimal value for a field. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `field` | `string` | The field with the minimal value. | + +#### Returns + +`Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +The [Entity](../README.md#entity) with the minimal value + +___ + +### minId + +▸ **minId**(`field`): `Promise`<``null`` \| `string`\> + +Finds the entity ID with the minimal value for a field. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `field` | `string` | The field with the minimal value. | + +#### Returns + +`Promise`<``null`` \| `string`\> + +The entity ID with the minimal value + +___ + +### minKey + +▸ **minKey**(`field`): `Promise`<``null`` \| `string`\> + +Finds the key name in Redis with the minimal value for a field. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `field` | `string` | The field with the minimal value. | + +#### Returns + +`Promise`<``null`` \| `string`\> + +The key name with the minimal value + +___ + +### page + +▸ **page**(`offset`, `count`): `Promise`<[`Entity`](../README.md#entity)[]\> + +Returns a page of [Entities](../README.md#entity) that match this query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `offset` | `number` | The offset for where to start returning [Entities](../README.md#entity). | +| `count` | `number` | The number of [Entities](../README.md#entity) to return. | + +#### Returns + +`Promise`<[`Entity`](../README.md#entity)[]\> + +An array of [Entities](../README.md#entity) matching the query. + +___ + +### pageOfIds + +▸ **pageOfIds**(`offset`, `count`): `Promise`<`string`[]\> + +Returns a page of entity IDs that match this query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `offset` | `number` | The offset for where to start returning entity IDs. | +| `count` | `number` | The number of entity IDs to return. | + +#### Returns + +`Promise`<`string`[]\> + +An array of strings matching the query. + +___ + +### pageOfKeys + +▸ **pageOfKeys**(`offset`, `count`): `Promise`<`string`[]\> + +Returns a page of key names in Redis that match this query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `offset` | `number` | The offset for where to start returning key names. | +| `count` | `number` | The number of key names to return. | + +#### Returns + +`Promise`<`string`[]\> + +An array of strings matching the query. + +___ + +### returnAll + +▸ **returnAll**(`options?`): `Promise`<[`Entity`](../README.md#entity)[]\> + +Alias for [all](Search.md#all). + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `options` | `Object` | `undefined` | +| `options.pageSize` | `number` | `10` | + +#### Returns + +`Promise`<[`Entity`](../README.md#entity)[]\> + +___ + +### returnAllIds + +▸ **returnAllIds**(`options?`): `Promise`<`string`[]\> + +Alias for [allIds](Search.md#allids). + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `options` | `Object` | `undefined` | +| `options.pageSize` | `number` | `10` | + +#### Returns + +`Promise`<`string`[]\> + +___ + +### returnAllKeys + +▸ **returnAllKeys**(`options?`): `Promise`<`string`[]\> + +Alias for [allKeys](Search.md#allkeys). + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `options` | `Object` | `undefined` | +| `options.pageSize` | `number` | `10` | + +#### Returns + +`Promise`<`string`[]\> + +___ + +### returnCount + +▸ **returnCount**(): `Promise`<`number`\> + +Alias for [count](Search.md#count). + +#### Returns + +`Promise`<`number`\> + +___ + +### returnFirst + +▸ **returnFirst**(): `Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +Alias for [first](Search.md#first). + +#### Returns + +`Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +___ + +### returnFirstId + +▸ **returnFirstId**(): `Promise`<``null`` \| `string`\> + +Alias for [firstId](Search.md#firstid). + +#### Returns + +`Promise`<``null`` \| `string`\> + +___ + +### returnFirstKey + +▸ **returnFirstKey**(): `Promise`<``null`` \| `string`\> + +Alias for [firstKey](Search.md#firstkey). + +#### Returns + +`Promise`<``null`` \| `string`\> + +___ + +### returnMax + +▸ **returnMax**(`field`): `Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +Alias for [max](Search.md#max). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `field` | `string` | + +#### Returns + +`Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +___ + +### returnMaxId + +▸ **returnMaxId**(`field`): `Promise`<``null`` \| `string`\> + +Alias for [maxId](Search.md#maxid). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `field` | `string` | + +#### Returns + +`Promise`<``null`` \| `string`\> + +___ + +### returnMaxKey + +▸ **returnMaxKey**(`field`): `Promise`<``null`` \| `string`\> + +Alias for [maxKey](Search.md#maxkey). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `field` | `string` | + +#### Returns + +`Promise`<``null`` \| `string`\> + +___ + +### returnMin + +▸ **returnMin**(`field`): `Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +Alias for [min](Search.md#min). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `field` | `string` | + +#### Returns + +`Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +___ + +### returnMinId + +▸ **returnMinId**(`field`): `Promise`<``null`` \| `string`\> + +Alias for [minId](Search.md#minid). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `field` | `string` | + +#### Returns + +`Promise`<``null`` \| `string`\> + +___ + +### returnMinKey + +▸ **returnMinKey**(`field`): `Promise`<``null`` \| `string`\> + +Alias for [minKey](Search.md#minkey). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `field` | `string` | + +#### Returns + +`Promise`<``null`` \| `string`\> + +___ + +### returnPage + +▸ **returnPage**(`offset`, `count`): `Promise`<[`Entity`](../README.md#entity)[]\> + +Alias for [page](Search.md#page). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `offset` | `number` | +| `count` | `number` | + +#### Returns + +`Promise`<[`Entity`](../README.md#entity)[]\> + +___ + +### returnPageOfIds + +▸ **returnPageOfIds**(`offset`, `count`): `Promise`<`string`[]\> + +Alias for [pageOfIds](Search.md#pageofids). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `offset` | `number` | +| `count` | `number` | + +#### Returns + +`Promise`<`string`[]\> + +___ + +### returnPageOfKeys + +▸ **returnPageOfKeys**(`offset`, `count`): `Promise`<`string`[]\> + +Alias for [pageOfKeys](Search.md#pageofkeys). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `offset` | `number` | +| `count` | `number` | + +#### Returns + +`Promise`<`string`[]\> + +___ + +### sortAsc + +▸ **sortAsc**(`field`): [`AbstractSearch`](AbstractSearch.md) + +Alias for [sortAscending](Search.md#sortascending). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `field` | `string` | + +#### Returns + +[`AbstractSearch`](AbstractSearch.md) + +___ + +### sortAscending + +▸ **sortAscending**(`field`): [`AbstractSearch`](AbstractSearch.md) + +Applies an ascending sort to the query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `field` | `string` | The field to sort by. | + +#### Returns + +[`AbstractSearch`](AbstractSearch.md) + +this + +___ + +### sortBy + +▸ **sortBy**(`fieldName`, `order?`): [`AbstractSearch`](AbstractSearch.md) + +Applies sorting for the query. + +#### Parameters + +| Name | Type | Default value | Description | +| :------ | :------ | :------ | :------ | +| `fieldName` | `string` | `undefined` | - | +| `order` | ``"ASC"`` \| ``"DESC"`` | `'ASC'` | The order of returned [Entities](../README.md#entity) Defaults to `ASC` (ascending) if not specified | + +#### Returns + +[`AbstractSearch`](AbstractSearch.md) + +this + +___ + +### sortDesc + +▸ **sortDesc**(`field`): [`AbstractSearch`](AbstractSearch.md) + +Alias for [sortDescending](Search.md#sortdescending). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `field` | `string` | + +#### Returns + +[`AbstractSearch`](AbstractSearch.md) + +___ + +### sortDescending + +▸ **sortDescending**(`field`): [`AbstractSearch`](AbstractSearch.md) + +Applies a descending sort to the query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `field` | `string` | The field to sort by. | + +#### Returns + +[`AbstractSearch`](AbstractSearch.md) + +this diff --git a/docs/classes/Circle.md b/docs/classes/Circle.md new file mode 100644 index 00000000..b734adc2 --- /dev/null +++ b/docs/classes/Circle.md @@ -0,0 +1,267 @@ +[redis-om](../README.md) / Circle + +# Class: Circle + +A builder that defines a circle. + +## Table of contents + +### Constructors + +- [constructor](Circle.md#constructor) + +### Accessors + +- [feet](Circle.md#feet) +- [foot](Circle.md#foot) +- [ft](Circle.md#ft) +- [kilometer](Circle.md#kilometer) +- [kilometers](Circle.md#kilometers) +- [km](Circle.md#km) +- [m](Circle.md#m) +- [meter](Circle.md#meter) +- [meters](Circle.md#meters) +- [mi](Circle.md#mi) +- [mile](Circle.md#mile) +- [miles](Circle.md#miles) + +### Methods + +- [latitude](Circle.md#latitude) +- [longitude](Circle.md#longitude) +- [radius](Circle.md#radius) + +## Constructors + +### constructor + +• **new Circle**() + +## Accessors + +### feet + +• `get` **feet**(): `this` + +Sets the units to feet. + +#### Returns + +`this` + +This instance. + +___ + +### foot + +• `get` **foot**(): `this` + +Sets the units to feet. + +#### Returns + +`this` + +This instance. + +___ + +### ft + +• `get` **ft**(): `this` + +Sets the units to feet. + +#### Returns + +`this` + +This instance. + +___ + +### kilometer + +• `get` **kilometer**(): `this` + +Sets the units to kilometers. + +#### Returns + +`this` + +This instance. + +___ + +### kilometers + +• `get` **kilometers**(): `this` + +Sets the units to kilometers. + +#### Returns + +`this` + +This instance. + +___ + +### km + +• `get` **km**(): `this` + +Sets the units to kilometers. + +#### Returns + +`this` + +This instance. + +___ + +### m + +• `get` **m**(): `this` + +Sets the units to meters. + +#### Returns + +`this` + +This instance. + +___ + +### meter + +• `get` **meter**(): `this` + +Sets the units to meters. + +#### Returns + +`this` + +This instance. + +___ + +### meters + +• `get` **meters**(): `this` + +Sets the units to meters. + +#### Returns + +`this` + +This instance. + +___ + +### mi + +• `get` **mi**(): `this` + +Sets the units to miles. + +#### Returns + +`this` + +This instance. + +___ + +### mile + +• `get` **mile**(): `this` + +Sets the units to miles. + +#### Returns + +`this` + +This instance. + +___ + +### miles + +• `get` **miles**(): `this` + +Sets the units to miles. + +#### Returns + +`this` + +This instance. + +## Methods + +### latitude + +▸ **latitude**(`value`): [`Circle`](Circle.md) + +Sets the latitude. If not set, defaults to 0.0. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `value` | `number` | The latitude. | + +#### Returns + +[`Circle`](Circle.md) + +This instance. + +___ + +### longitude + +▸ **longitude**(`value`): [`Circle`](Circle.md) + +Sets the longitude. If not set, defaults to 0.0. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `value` | `number` | The longitude. | + +#### Returns + +[`Circle`](Circle.md) + +This instance. + +___ + +### radius + +▸ **radius**(`size`): [`Circle`](Circle.md) + +Sets the radius of the [Circle](Circle.md). Defaults to 1. If units are +not specified, defaults to meters. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `size` | `number` | The radius of the circle. | + +#### Returns + +[`Circle`](Circle.md) + +This instance. diff --git a/docs/classes/Client.md b/docs/classes/Client.md new file mode 100644 index 00000000..266ec94d --- /dev/null +++ b/docs/classes/Client.md @@ -0,0 +1,141 @@ +[redis-om](../README.md) / Client + +# Class: Client + +A Client is the starting point for working with Redis OM. Clients manage the +connection to Redis and provide limited functionality for executing Redis commands. +Create a client and open it before you use it: + +```typescript +const client = new Client() +await client.open() +``` + +A Client is primarily used by a [Repository](Repository.md) which requires a client in +its constructor. + +## Table of contents + +### Constructors + +- [constructor](Client.md#constructor) + +### Methods + +- [close](Client.md#close) +- [execute](Client.md#execute) +- [fetchRepository](Client.md#fetchrepository) +- [isOpen](Client.md#isopen) +- [open](Client.md#open) +- [use](Client.md#use) + +## Constructors + +### constructor + +• **new Client**() + +## Methods + +### close + +▸ **close**(): `Promise`<`void`\> + +Close the connection to Redis. + +#### Returns + +`Promise`<`void`\> + +___ + +### execute + +▸ **execute**(`command`): `Promise`<`unknown`\> + +Execute an arbitrary Redis command. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `command` | (`string` \| `number` \| `boolean`)[] | The command to execute. | + +#### Returns + +`Promise`<`unknown`\> + +The raw results of calling the Redis command. + +___ + +### fetchRepository + +▸ **fetchRepository**(`schema`): [`Repository`](Repository.md) + +Creates a repository for the given schema. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `schema` | [`Schema`](Schema.md) | The schema. | + +#### Returns + +[`Repository`](Repository.md) + +A repository for the provided schema. + +___ + +### isOpen + +▸ **isOpen**(): `boolean` + +#### Returns + +`boolean` + +Whether a connection is already open. + +___ + +### open + +▸ **open**(`url?`): `Promise`<[`Client`](Client.md)\> + +Open a connection to Redis at the provided URL. + +#### Parameters + +| Name | Type | Default value | Description | +| :------ | :------ | :------ | :------ | +| `url` | `string` | `'redis://localhost:6379'` | A URL to Redis as defined with the [IANA](https://www.iana.org/assignments/uri-schemes/prov/redis). | + +#### Returns + +`Promise`<[`Client`](Client.md)\> + +This [Client](Client.md) instance. + +___ + +### use + +▸ **use**(`connection`): `Promise`<[`Client`](Client.md)\> + +Attaches an existing Node Redis connection to this Redis OM client. Closes +any existing connection. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `connection` | `RedisClientType`<{ `bf`: { `ADD`: `__module` ; `EXISTS`: `__module` ; `INFO`: `__module` ; `INSERT`: `__module` ; `LOADCHUNK`: `__module` ; `MADD`: `__module` ; `MEXISTS`: `__module` ; `RESERVE`: `__module` ; `SCANDUMP`: `__module` ; `add`: `__module` ; `exists`: `__module` ; `info`: `__module` ; `insert`: `__module` ; `loadChunk`: `__module` ; `mAdd`: `__module` ; `mExists`: `__module` ; `reserve`: `__module` ; `scanDump`: `__module` } ; `cf`: { `ADD`: `__module` ; `ADDNX`: `__module` ; `COUNT`: `__module` ; `DEL`: `__module` ; `EXISTS`: `__module` ; `INFO`: `__module` ; `INSERT`: `__module` ; `INSERTNX`: `__module` ; `LOADCHUNK`: `__module` ; `RESERVE`: `__module` ; `SCANDUMP`: `__module` ; `add`: `__module` ; `addNX`: `__module` ; `count`: `__module` ; `del`: `__module` ; `exists`: `__module` ; `info`: `__module` ; `insert`: `__module` ; `insertNX`: `__module` ; `loadChunk`: `__module` ; `reserve`: `__module` ; `scanDump`: `__module` } ; `cms`: { `INCRBY`: `__module` ; `INFO`: `__module` ; `INITBYDIM`: `__module` ; `INITBYPROB`: `__module` ; `MERGE`: `__module` ; `QUERY`: `__module` ; `incrBy`: `__module` ; `info`: `__module` ; `initByDim`: `__module` ; `initByProb`: `__module` ; `merge`: `__module` ; `query`: `__module` } ; `ft`: { `AGGREGATE`: `__module` ; `ALIASADD`: `__module` ; `ALIASDEL`: `__module` ; `ALIASUPDATE`: `__module` ; `ALTER`: `__module` ; `CONFIG_GET`: `__module` ; `CONFIG_SET`: `__module` ; `CREATE`: `__module` ; `DICTADD`: `__module` ; `DICTDEL`: `__module` ; `DICTDUMP`: `__module` ; `DROPINDEX`: `__module` ; `EXPLAIN`: `__module` ; `EXPLAINCLI`: `__module` ; `INFO`: `__module` ; `PROFILEAGGREGATE`: `__module` ; `PROFILESEARCH`: `__module` ; `SEARCH`: `__module` ; `SPELLCHECK`: `__module` ; `SUGADD`: `__module` ; `SUGDEL`: `__module` ; `SUGGET`: `__module` ; `SUGGET_WITHPAYLOADS`: `__module` ; `SUGGET_WITHSCORES`: `__module` ; `SUGGET_WITHSCORES_WITHPAYLOADS`: `__module` ; `SUGLEN`: `__module` ; `SYNDUMP`: `__module` ; `SYNUPDATE`: `__module` ; `TAGVALS`: `__module` ; `_LIST`: `__module` ; `_list`: `__module` ; `aggregate`: `__module` ; `aliasAdd`: `__module` ; `aliasDel`: `__module` ; `aliasUpdate`: `__module` ; `alter`: `__module` ; `configGet`: `__module` ; `configSet`: `__module` ; `create`: `__module` ; `dictAdd`: `__module` ; `dictDel`: `__module` ; `dictDump`: `__module` ; `dropIndex`: `__module` ; `explain`: `__module` ; `explainCli`: `__module` ; `info`: `__module` ; `profileAggregate`: `__module` ; `profileSearch`: `__module` ; `search`: `__module` ; `spellCheck`: `__module` ; `sugAdd`: `__module` ; `sugDel`: `__module` ; `sugGet`: `__module` ; `sugGetWithPayloads`: `__module` ; `sugGetWithScores`: `__module` ; `sugGetWithScoresWithPayloads`: `__module` ; `sugLen`: `__module` ; `synDump`: `__module` ; `synUpdate`: `__module` ; `tagVals`: `__module` } ; `graph`: { `CONFIG_GET`: `__module` ; `CONFIG_SET`: `__module` ; `DELETE`: `__module` ; `EXPLAIN`: `__module` ; `LIST`: `__module` ; `PROFILE`: `__module` ; `QUERY`: `__module` ; `QUERY_RO`: `__module` ; `SLOWLOG`: `__module` ; `configGet`: `__module` ; `configSet`: `__module` ; `delete`: `__module` ; `explain`: `__module` ; `list`: `__module` ; `profile`: `__module` ; `query`: `__module` ; `queryRo`: `__module` ; `slowLog`: `__module` } ; `json`: { `ARRAPPEND`: `__module` ; `ARRINDEX`: `__module` ; `ARRINSERT`: `__module` ; `ARRLEN`: `__module` ; `ARRPOP`: `__module` ; `ARRTRIM`: `__module` ; `DEBUG_MEMORY`: `__module` ; `DEL`: `__module` ; `FORGET`: `__module` ; `GET`: `__module` ; `MGET`: `__module` ; `NUMINCRBY`: `__module` ; `NUMMULTBY`: `__module` ; `OBJKEYS`: `__module` ; `OBJLEN`: `__module` ; `RESP`: `__module` ; `SET`: `__module` ; `STRAPPEND`: `__module` ; `STRLEN`: `__module` ; `TYPE`: `__module` ; `arrAppend`: `__module` ; `arrIndex`: `__module` ; `arrInsert`: `__module` ; `arrLen`: `__module` ; `arrPop`: `__module` ; `arrTrim`: `__module` ; `debugMemory`: `__module` ; `del`: `__module` ; `forget`: `__module` ; `get`: `__module` ; `mGet`: `__module` ; `numIncrBy`: `__module` ; `numMultBy`: `__module` ; `objKeys`: `__module` ; `objLen`: `__module` ; `resp`: `__module` ; `set`: `__module` ; `strAppend`: `__module` ; `strLen`: `__module` ; `type`: `__module` } ; `topK`: { `ADD`: `__module` ; `COUNT`: `__module` ; `INCRBY`: `__module` ; `INFO`: `__module` ; `LIST`: `__module` ; `LIST_WITHCOUNT`: `__module` ; `QUERY`: `__module` ; `RESERVE`: `__module` ; `add`: `__module` ; `count`: `__module` ; `incrBy`: `__module` ; `info`: `__module` ; `list`: `__module` ; `listWithCount`: `__module` ; `query`: `__module` ; `reserve`: `__module` } ; `ts`: { `ADD`: `__module` ; `ALTER`: `__module` ; `CREATE`: `__module` ; `CREATERULE`: `__module` ; `DECRBY`: `__module` ; `DEL`: `__module` ; `DELETERULE`: `__module` ; `GET`: `__module` ; `INCRBY`: `__module` ; `INFO`: `__module` ; `INFO_DEBUG`: `__module` ; `MADD`: `__module` ; `MGET`: `__module` ; `MGET_WITHLABELS`: `__module` ; `MRANGE`: `__module` ; `MRANGE_WITHLABELS`: `__module` ; `MREVRANGE`: `__module` ; `MREVRANGE_WITHLABELS`: `__module` ; `QUERYINDEX`: `__module` ; `RANGE`: `__module` ; `REVRANGE`: `__module` ; `add`: `__module` ; `alter`: `__module` ; `create`: `__module` ; `createRule`: `__module` ; `decrBy`: `__module` ; `del`: `__module` ; `deleteRule`: `__module` ; `get`: `__module` ; `incrBy`: `__module` ; `info`: `__module` ; `infoDebug`: `__module` ; `mAdd`: `__module` ; `mGet`: `__module` ; `mGetWithLabels`: `__module` ; `mRange`: `__module` ; `mRangeWithLabels`: `__module` ; `mRevRange`: `__module` ; `mRevRangeWithLabels`: `__module` ; `queryIndex`: `__module` ; `range`: `__module` ; `revRange`: `__module` } } & `RedisModules`, `RedisFunctions`, `RedisScripts`\> | An existing Node Redis client. | + +#### Returns + +`Promise`<[`Client`](Client.md)\> + +This [Client](Client.md) instance. diff --git a/docs/classes/Field.md b/docs/classes/Field.md new file mode 100644 index 00000000..83c42636 --- /dev/null +++ b/docs/classes/Field.md @@ -0,0 +1,185 @@ +[redis-om](../README.md) / Field + +# Class: Field + +Describes a field in a [Schema](Schema.md). + +## Table of contents + +### Constructors + +- [constructor](Field.md#constructor) + +### Accessors + +- [caseSensitive](Field.md#casesensitive) +- [hashField](Field.md#hashfield) +- [indexed](Field.md#indexed) +- [jsonPath](Field.md#jsonpath) +- [matcher](Field.md#matcher) +- [name](Field.md#name) +- [normalized](Field.md#normalized) +- [separator](Field.md#separator) +- [sortable](Field.md#sortable) +- [stemming](Field.md#stemming) +- [type](Field.md#type) +- [weight](Field.md#weight) + +## Constructors + +### constructor + +• **new Field**(`name`, `definition`) + +Creates a Field. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `name` | `string` | The name of the Field. | +| `definition` | [`FieldDefinition`](../README.md#fielddefinition) | The underlying [FieldDefinition](../README.md#fielddefinition). | + +## Accessors + +### caseSensitive + +• `get` **caseSensitive**(): `boolean` + +The case-sensitivity of the field. + +#### Returns + +`boolean` + +___ + +### hashField + +• `get` **hashField**(): `string` + +The field name used to store this [Field](Field.md) in a Hash. + +#### Returns + +`string` + +___ + +### indexed + +• `get` **indexed**(): `boolean` + +Indicates the field as being indexed—and thus queryable—by RediSearch. + +#### Returns + +`boolean` + +___ + +### jsonPath + +• `get` **jsonPath**(): `string` + +The JSONPath used to store this [Field](Field.md) in a JSON document. + +#### Returns + +`string` + +___ + +### matcher + +• `get` **matcher**(): ``null`` \| `string` + +The phonetic matcher for the field. + +#### Returns + +``null`` \| `string` + +___ + +### name + +• `get` **name**(): `string` + +The name of the field. + +#### Returns + +`string` + +___ + +### normalized + +• `get` **normalized**(): `boolean` + +Inidicates that the field is normalized. + +#### Returns + +`boolean` + +___ + +### separator + +• `get` **separator**(): `string` + +The separator for string[] fields when stored in Hashes. + +#### Returns + +`string` + +___ + +### sortable + +• `get` **sortable**(): `boolean` + +Indicates that the field as sortable. + +#### Returns + +`boolean` + +___ + +### stemming + +• `get` **stemming**(): `boolean` + +Indicates that the field as indexed with stemming support. + +#### Returns + +`boolean` + +___ + +### type + +• `get` **type**(): [`FieldType`](../README.md#fieldtype) + +The [type](../README.md#fieldtype) of the field. + +#### Returns + +[`FieldType`](../README.md#fieldtype) + +___ + +### weight + +• `get` **weight**(): ``null`` \| `number` + +The search weight of the field. + +#### Returns + +``null`` \| `number` diff --git a/docs/classes/RawSearch.md b/docs/classes/RawSearch.md new file mode 100644 index 00000000..5158918e --- /dev/null +++ b/docs/classes/RawSearch.md @@ -0,0 +1,909 @@ +[redis-om](../README.md) / RawSearch + +# Class: RawSearch + +Entry point to raw search which allows using raw RediSearch queries +against Redis OM. Requires that RediSearch (and optionally RedisJSON) be +installed. + +**`template`** The type of [Entity](../README.md#entity) being sought. + +## Hierarchy + +- [`AbstractSearch`](AbstractSearch.md) + + ↳ **`RawSearch`** + +## Table of contents + +### Accessors + +- [return](RawSearch.md#return) + +### Methods + +- [all](RawSearch.md#all) +- [allIds](RawSearch.md#allids) +- [allKeys](RawSearch.md#allkeys) +- [count](RawSearch.md#count) +- [first](RawSearch.md#first) +- [firstId](RawSearch.md#firstid) +- [firstKey](RawSearch.md#firstkey) +- [max](RawSearch.md#max) +- [maxId](RawSearch.md#maxid) +- [maxKey](RawSearch.md#maxkey) +- [min](RawSearch.md#min) +- [minId](RawSearch.md#minid) +- [minKey](RawSearch.md#minkey) +- [page](RawSearch.md#page) +- [pageOfIds](RawSearch.md#pageofids) +- [pageOfKeys](RawSearch.md#pageofkeys) +- [returnAll](RawSearch.md#returnall) +- [returnAllIds](RawSearch.md#returnallids) +- [returnAllKeys](RawSearch.md#returnallkeys) +- [returnCount](RawSearch.md#returncount) +- [returnFirst](RawSearch.md#returnfirst) +- [returnFirstId](RawSearch.md#returnfirstid) +- [returnFirstKey](RawSearch.md#returnfirstkey) +- [returnMax](RawSearch.md#returnmax) +- [returnMaxId](RawSearch.md#returnmaxid) +- [returnMaxKey](RawSearch.md#returnmaxkey) +- [returnMin](RawSearch.md#returnmin) +- [returnMinId](RawSearch.md#returnminid) +- [returnMinKey](RawSearch.md#returnminkey) +- [returnPage](RawSearch.md#returnpage) +- [returnPageOfIds](RawSearch.md#returnpageofids) +- [returnPageOfKeys](RawSearch.md#returnpageofkeys) +- [sortAsc](RawSearch.md#sortasc) +- [sortAscending](RawSearch.md#sortascending) +- [sortBy](RawSearch.md#sortby) +- [sortDesc](RawSearch.md#sortdesc) +- [sortDescending](RawSearch.md#sortdescending) + +## Accessors + +### return + +• `get` **return**(): [`AbstractSearch`](AbstractSearch.md) + +Returns the current instance. Syntactic sugar to make your code more fluent. + +#### Returns + +[`AbstractSearch`](AbstractSearch.md) + +this + +#### Inherited from + +AbstractSearch.return + +## Methods + +### all + +▸ **all**(`options?`): `Promise`<[`Entity`](../README.md#entity)[]\> + +Returns all the [Entities](../README.md#entity) that match this query. This method +makes multiple calls to Redis until all the [Entities](../README.md#entity) are returned. +You can specify the batch size by setting the `pageSize` property on the +options: + +```typescript +const entities = await repository.search().returnAll({ pageSize: 100 }) +``` + +#### Parameters + +| Name | Type | Default value | Description | +| :------ | :------ | :------ | :------ | +| `options` | `Object` | `undefined` | Options for the call. | +| `options.pageSize` | `number` | `10` | Number of [Entities](../README.md#entity) returned per batch. | + +#### Returns + +`Promise`<[`Entity`](../README.md#entity)[]\> + +An array of [Entities](../README.md#entity) matching the query. + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[all](AbstractSearch.md#all) + +___ + +### allIds + +▸ **allIds**(`options?`): `Promise`<`string`[]\> + +Returns all the entity IDs that match this query. This method +makes multiple calls to Redis until all the entity IDs are returned. +You can specify the batch size by setting the `pageSize` property on the +options: + +```typescript +const keys = await repository.search().returnAllIds({ pageSize: 100 }) +``` + +#### Parameters + +| Name | Type | Default value | Description | +| :------ | :------ | :------ | :------ | +| `options` | `Object` | `undefined` | Options for the call. | +| `options.pageSize` | `number` | `10` | Number of entity IDs returned per batch. | + +#### Returns + +`Promise`<`string`[]\> + +An array of entity IDs matching the query. + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[allIds](AbstractSearch.md#allids) + +___ + +### allKeys + +▸ **allKeys**(`options?`): `Promise`<`string`[]\> + +Returns all the key names in Redis that match this query. This method +makes multiple calls to Redis until all the key names are returned. +You can specify the batch size by setting the `pageSize` property on the +options: + +```typescript +const keys = await repository.search().returnAllKeys({ pageSize: 100 }) +``` + +#### Parameters + +| Name | Type | Default value | Description | +| :------ | :------ | :------ | :------ | +| `options` | `Object` | `undefined` | Options for the call. | +| `options.pageSize` | `number` | `10` | Number of key names returned per batch. | + +#### Returns + +`Promise`<`string`[]\> + +An array of key names matching the query. + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[allKeys](AbstractSearch.md#allkeys) + +___ + +### count + +▸ **count**(): `Promise`<`number`\> + +Returns the number of [Entities](../README.md#entity) that match this query. + +#### Returns + +`Promise`<`number`\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[count](AbstractSearch.md#count) + +___ + +### first + +▸ **first**(): `Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +Returns the first [Entity](../README.md#entity) that matches this query. + +#### Returns + +`Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[first](AbstractSearch.md#first) + +___ + +### firstId + +▸ **firstId**(): `Promise`<``null`` \| `string`\> + +Returns the first entity ID that matches this query. + +#### Returns + +`Promise`<``null`` \| `string`\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[firstId](AbstractSearch.md#firstid) + +___ + +### firstKey + +▸ **firstKey**(): `Promise`<``null`` \| `string`\> + +Returns the first key name that matches this query. + +#### Returns + +`Promise`<``null`` \| `string`\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[firstKey](AbstractSearch.md#firstkey) + +___ + +### max + +▸ **max**(`field`): `Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +Finds the [Entity](../README.md#entity) with the maximal value for a field. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `field` | `string` | The field with the maximal value. | + +#### Returns + +`Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +The entity ID [Entity](../README.md#entity) with the maximal value + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[max](AbstractSearch.md#max) + +___ + +### maxId + +▸ **maxId**(`field`): `Promise`<``null`` \| `string`\> + +Finds the entity ID with the maximal value for a field. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `field` | `string` | The field with the maximal value. | + +#### Returns + +`Promise`<``null`` \| `string`\> + +The entity ID with the maximal value + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[maxId](AbstractSearch.md#maxid) + +___ + +### maxKey + +▸ **maxKey**(`field`): `Promise`<``null`` \| `string`\> + +Finds the key name in Redis with the maximal value for a field. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `field` | `string` | The field with the maximal value. | + +#### Returns + +`Promise`<``null`` \| `string`\> + +The key name with the maximal value + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[maxKey](AbstractSearch.md#maxkey) + +___ + +### min + +▸ **min**(`field`): `Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +Finds the [Entity](../README.md#entity) with the minimal value for a field. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `field` | `string` | The field with the minimal value. | + +#### Returns + +`Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +The [Entity](../README.md#entity) with the minimal value + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[min](AbstractSearch.md#min) + +___ + +### minId + +▸ **minId**(`field`): `Promise`<``null`` \| `string`\> + +Finds the entity ID with the minimal value for a field. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `field` | `string` | The field with the minimal value. | + +#### Returns + +`Promise`<``null`` \| `string`\> + +The entity ID with the minimal value + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[minId](AbstractSearch.md#minid) + +___ + +### minKey + +▸ **minKey**(`field`): `Promise`<``null`` \| `string`\> + +Finds the key name in Redis with the minimal value for a field. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `field` | `string` | The field with the minimal value. | + +#### Returns + +`Promise`<``null`` \| `string`\> + +The key name with the minimal value + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[minKey](AbstractSearch.md#minkey) + +___ + +### page + +▸ **page**(`offset`, `count`): `Promise`<[`Entity`](../README.md#entity)[]\> + +Returns a page of [Entities](../README.md#entity) that match this query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `offset` | `number` | The offset for where to start returning [Entities](../README.md#entity). | +| `count` | `number` | The number of [Entities](../README.md#entity) to return. | + +#### Returns + +`Promise`<[`Entity`](../README.md#entity)[]\> + +An array of [Entities](../README.md#entity) matching the query. + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[page](AbstractSearch.md#page) + +___ + +### pageOfIds + +▸ **pageOfIds**(`offset`, `count`): `Promise`<`string`[]\> + +Returns a page of entity IDs that match this query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `offset` | `number` | The offset for where to start returning entity IDs. | +| `count` | `number` | The number of entity IDs to return. | + +#### Returns + +`Promise`<`string`[]\> + +An array of strings matching the query. + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[pageOfIds](AbstractSearch.md#pageofids) + +___ + +### pageOfKeys + +▸ **pageOfKeys**(`offset`, `count`): `Promise`<`string`[]\> + +Returns a page of key names in Redis that match this query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `offset` | `number` | The offset for where to start returning key names. | +| `count` | `number` | The number of key names to return. | + +#### Returns + +`Promise`<`string`[]\> + +An array of strings matching the query. + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[pageOfKeys](AbstractSearch.md#pageofkeys) + +___ + +### returnAll + +▸ **returnAll**(`options?`): `Promise`<[`Entity`](../README.md#entity)[]\> + +Alias for [all](Search.md#all). + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `options` | `Object` | `undefined` | +| `options.pageSize` | `number` | `10` | + +#### Returns + +`Promise`<[`Entity`](../README.md#entity)[]\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnAll](AbstractSearch.md#returnall) + +___ + +### returnAllIds + +▸ **returnAllIds**(`options?`): `Promise`<`string`[]\> + +Alias for [allIds](Search.md#allids). + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `options` | `Object` | `undefined` | +| `options.pageSize` | `number` | `10` | + +#### Returns + +`Promise`<`string`[]\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnAllIds](AbstractSearch.md#returnallids) + +___ + +### returnAllKeys + +▸ **returnAllKeys**(`options?`): `Promise`<`string`[]\> + +Alias for [allKeys](Search.md#allkeys). + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `options` | `Object` | `undefined` | +| `options.pageSize` | `number` | `10` | + +#### Returns + +`Promise`<`string`[]\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnAllKeys](AbstractSearch.md#returnallkeys) + +___ + +### returnCount + +▸ **returnCount**(): `Promise`<`number`\> + +Alias for [count](Search.md#count). + +#### Returns + +`Promise`<`number`\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnCount](AbstractSearch.md#returncount) + +___ + +### returnFirst + +▸ **returnFirst**(): `Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +Alias for [first](Search.md#first). + +#### Returns + +`Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnFirst](AbstractSearch.md#returnfirst) + +___ + +### returnFirstId + +▸ **returnFirstId**(): `Promise`<``null`` \| `string`\> + +Alias for [firstId](Search.md#firstid). + +#### Returns + +`Promise`<``null`` \| `string`\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnFirstId](AbstractSearch.md#returnfirstid) + +___ + +### returnFirstKey + +▸ **returnFirstKey**(): `Promise`<``null`` \| `string`\> + +Alias for [firstKey](Search.md#firstkey). + +#### Returns + +`Promise`<``null`` \| `string`\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnFirstKey](AbstractSearch.md#returnfirstkey) + +___ + +### returnMax + +▸ **returnMax**(`field`): `Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +Alias for [max](Search.md#max). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `field` | `string` | + +#### Returns + +`Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnMax](AbstractSearch.md#returnmax) + +___ + +### returnMaxId + +▸ **returnMaxId**(`field`): `Promise`<``null`` \| `string`\> + +Alias for [maxId](Search.md#maxid). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `field` | `string` | + +#### Returns + +`Promise`<``null`` \| `string`\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnMaxId](AbstractSearch.md#returnmaxid) + +___ + +### returnMaxKey + +▸ **returnMaxKey**(`field`): `Promise`<``null`` \| `string`\> + +Alias for [maxKey](Search.md#maxkey). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `field` | `string` | + +#### Returns + +`Promise`<``null`` \| `string`\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnMaxKey](AbstractSearch.md#returnmaxkey) + +___ + +### returnMin + +▸ **returnMin**(`field`): `Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +Alias for [min](Search.md#min). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `field` | `string` | + +#### Returns + +`Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnMin](AbstractSearch.md#returnmin) + +___ + +### returnMinId + +▸ **returnMinId**(`field`): `Promise`<``null`` \| `string`\> + +Alias for [minId](Search.md#minid). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `field` | `string` | + +#### Returns + +`Promise`<``null`` \| `string`\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnMinId](AbstractSearch.md#returnminid) + +___ + +### returnMinKey + +▸ **returnMinKey**(`field`): `Promise`<``null`` \| `string`\> + +Alias for [minKey](Search.md#minkey). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `field` | `string` | + +#### Returns + +`Promise`<``null`` \| `string`\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnMinKey](AbstractSearch.md#returnminkey) + +___ + +### returnPage + +▸ **returnPage**(`offset`, `count`): `Promise`<[`Entity`](../README.md#entity)[]\> + +Alias for [page](Search.md#page). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `offset` | `number` | +| `count` | `number` | + +#### Returns + +`Promise`<[`Entity`](../README.md#entity)[]\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnPage](AbstractSearch.md#returnpage) + +___ + +### returnPageOfIds + +▸ **returnPageOfIds**(`offset`, `count`): `Promise`<`string`[]\> + +Alias for [pageOfIds](Search.md#pageofids). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `offset` | `number` | +| `count` | `number` | + +#### Returns + +`Promise`<`string`[]\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnPageOfIds](AbstractSearch.md#returnpageofids) + +___ + +### returnPageOfKeys + +▸ **returnPageOfKeys**(`offset`, `count`): `Promise`<`string`[]\> + +Alias for [pageOfKeys](Search.md#pageofkeys). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `offset` | `number` | +| `count` | `number` | + +#### Returns + +`Promise`<`string`[]\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnPageOfKeys](AbstractSearch.md#returnpageofkeys) + +___ + +### sortAsc + +▸ **sortAsc**(`field`): [`AbstractSearch`](AbstractSearch.md) + +Alias for [sortAscending](Search.md#sortascending). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `field` | `string` | + +#### Returns + +[`AbstractSearch`](AbstractSearch.md) + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[sortAsc](AbstractSearch.md#sortasc) + +___ + +### sortAscending + +▸ **sortAscending**(`field`): [`AbstractSearch`](AbstractSearch.md) + +Applies an ascending sort to the query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `field` | `string` | The field to sort by. | + +#### Returns + +[`AbstractSearch`](AbstractSearch.md) + +this + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[sortAscending](AbstractSearch.md#sortascending) + +___ + +### sortBy + +▸ **sortBy**(`fieldName`, `order?`): [`AbstractSearch`](AbstractSearch.md) + +Applies sorting for the query. + +#### Parameters + +| Name | Type | Default value | Description | +| :------ | :------ | :------ | :------ | +| `fieldName` | `string` | `undefined` | - | +| `order` | ``"ASC"`` \| ``"DESC"`` | `'ASC'` | The order of returned [Entities](../README.md#entity) Defaults to `ASC` (ascending) if not specified | + +#### Returns + +[`AbstractSearch`](AbstractSearch.md) + +this + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[sortBy](AbstractSearch.md#sortby) + +___ + +### sortDesc + +▸ **sortDesc**(`field`): [`AbstractSearch`](AbstractSearch.md) + +Alias for [sortDescending](Search.md#sortdescending). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `field` | `string` | + +#### Returns + +[`AbstractSearch`](AbstractSearch.md) + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[sortDesc](AbstractSearch.md#sortdesc) + +___ + +### sortDescending + +▸ **sortDescending**(`field`): [`AbstractSearch`](AbstractSearch.md) + +Applies a descending sort to the query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `field` | `string` | The field to sort by. | + +#### Returns + +[`AbstractSearch`](AbstractSearch.md) + +this + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[sortDescending](AbstractSearch.md#sortdescending) diff --git a/docs/classes/RedisError.md b/docs/classes/RedisError.md new file mode 100644 index 00000000..d454f61a --- /dev/null +++ b/docs/classes/RedisError.md @@ -0,0 +1,170 @@ +[redis-om](../README.md) / RedisError + +# Class: RedisError + +## Hierarchy + +- `Error` + + ↳ **`RedisError`** + +## Table of contents + +### Constructors + +- [constructor](RedisError.md#constructor) + +### Properties + +- [cause](RedisError.md#cause) +- [message](RedisError.md#message) +- [name](RedisError.md#name) +- [stack](RedisError.md#stack) +- [prepareStackTrace](RedisError.md#preparestacktrace) +- [stackTraceLimit](RedisError.md#stacktracelimit) + +### Methods + +- [captureStackTrace](RedisError.md#capturestacktrace) + +## Constructors + +### constructor + +• **new RedisError**(`message`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `message` | `string` | + +#### Overrides + +Error.constructor + +## Properties + +### cause + +• `Optional` **cause**: `Error` + +#### Inherited from + +Error.cause + +#### Defined in + +node_modules/typescript/lib/lib.es2022.error.d.ts:26 + +___ + +### message + +• **message**: `string` + +#### Inherited from + +Error.message + +#### Defined in + +node_modules/typescript/lib/lib.es5.d.ts:1029 + +___ + +### name + +• **name**: `string` + +#### Inherited from + +Error.name + +#### Defined in + +node_modules/typescript/lib/lib.es5.d.ts:1028 + +___ + +### stack + +• `Optional` **stack**: `string` + +#### Inherited from + +Error.stack + +#### Defined in + +node_modules/typescript/lib/lib.es5.d.ts:1030 + +___ + +### prepareStackTrace + +▪ `Static` `Optional` **prepareStackTrace**: (`err`: `Error`, `stackTraces`: `CallSite`[]) => `any` + +#### Type declaration + +▸ (`err`, `stackTraces`): `any` + +Optional override for formatting stack traces + +**`see`** https://v8.dev/docs/stack-trace-api#customizing-stack-traces + +##### Parameters + +| Name | Type | +| :------ | :------ | +| `err` | `Error` | +| `stackTraces` | `CallSite`[] | + +##### Returns + +`any` + +#### Inherited from + +Error.prepareStackTrace + +#### Defined in + +node_modules/@types/node/globals.d.ts:11 + +___ + +### stackTraceLimit + +▪ `Static` **stackTraceLimit**: `number` + +#### Inherited from + +Error.stackTraceLimit + +#### Defined in + +node_modules/@types/node/globals.d.ts:13 + +## Methods + +### captureStackTrace + +▸ `Static` **captureStackTrace**(`targetObject`, `constructorOpt?`): `void` + +Create .stack property on a target object + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `targetObject` | `object` | +| `constructorOpt?` | `Function` | + +#### Returns + +`void` + +#### Inherited from + +Error.captureStackTrace diff --git a/docs/classes/Repository.md b/docs/classes/Repository.md new file mode 100644 index 00000000..e6333f9f --- /dev/null +++ b/docs/classes/Repository.md @@ -0,0 +1,423 @@ +[redis-om](../README.md) / Repository + +# Class: Repository + +A repository is the main interaction point for reading, writing, and +removing [Entities](../README.md#entity) from Redis. Create one by calling +[fetchRepository](Client.md#fetchrepository) and passing in a [Schema](Schema.md). Then +use the [fetch](Repository.md#fetch), [save](Repository.md#save), and +[remove](Repository.md#remove) methods to manage your data: + +```typescript +const repository = client.fetchRepository(schema) + +const foo = await repository.fetch('01FK6TCJBDK41RJ766A4SBWDJ9') +foo.aString = 'bar' +foo.aBoolean = false +await repository.save(foo) +``` + +Use the repository to create a new instance of an [Entity](../README.md#entity) +before you save it: + +```typescript +const foo = await repository.createEntity() +foo.aString = 'bar' +foo.aBoolean = false +await repository.save(foo) +``` + +If you want to use the [search](Repository.md#search) method, you need to create an index +first, and you need RediSearch or RedisJSON installed on your instance of Redis: + +```typescript +await repository.createIndex() +const entities = await repository.search() + .where('aString').eq('bar') + .and('aBoolean').is.false().returnAll() +``` + +## Table of contents + +### Constructors + +- [constructor](Repository.md#constructor) + +### Methods + +- [createAndSave](Repository.md#createandsave) +- [createEntity](Repository.md#createentity) +- [createIndex](Repository.md#createindex) +- [dropIndex](Repository.md#dropindex) +- [expire](Repository.md#expire) +- [fetch](Repository.md#fetch) +- [remove](Repository.md#remove) +- [save](Repository.md#save) +- [search](Repository.md#search) +- [searchRaw](Repository.md#searchraw) + +## Constructors + +### constructor + +• **new Repository**(`schema`, `client`) + +Creates a new [Repository](Repository.md). Equivalent to calling +[fetchRepository](Client.md#fetchrepository). + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `schema` | [`Schema`](Schema.md) | The schema defining that data in the repository. | +| `client` | [`Client`](Client.md) | A client to talk to Redis. | + +## Methods + +### createAndSave + +▸ **createAndSave**(`entityData`): `Promise`<[`Entity`](../README.md#entity)\> + +Creates and saves an [Entity](../README.md#entity). Equivalent of calling +[createEntity](Repository.md#createentity) followed by [save](Repository.md#save). + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `entityData` | [`EntityData`](../README.md#entitydata) | The data to be saved. | + +#### Returns + +`Promise`<[`Entity`](../README.md#entity)\> + +The newly created and saved Entity. + +▸ **createAndSave**(`id`, `entityData`): `Promise`<[`Entity`](../README.md#entity)\> + +Creates and saves an [Entity](../README.md#entity) to using the provided entityId. Equivalent +of calling [createEntity](Repository.md#createentity) followed by [save](Repository.md#save). + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `id` | `string` | The entityId to save to. | +| `entityData` | [`EntityData`](../README.md#entitydata) | The data to be saved. | + +#### Returns + +`Promise`<[`Entity`](../README.md#entity)\> + +The newly created and saved Entity. + +___ + +### createEntity + +▸ **createEntity**(): [`Entity`](../README.md#entity) + +Creates an empty [Entity](../README.md#entity) with a generated entityId property. + +#### Returns + +[`Entity`](../README.md#entity) + +A newly created Entity. + +▸ **createEntity**(`id`): [`Entity`](../README.md#entity) + +Creates an empty [Entity](../README.md#entity) with a provided entityId. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `id` | `string` | The provided entityId. | + +#### Returns + +[`Entity`](../README.md#entity) + +A newly created Entity. + +▸ **createEntity**(`entityData`): [`Entity`](../README.md#entity) + +Creates an [Entity](../README.md#entity) populated with provided data and a generated entityId property. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `entityData` | [`EntityData`](../README.md#entitydata) | The provided entity data. | + +#### Returns + +[`Entity`](../README.md#entity) + +A newly created Entity. + +▸ **createEntity**(`id`, `entityData`): [`Entity`](../README.md#entity) + +Creates an [Entity](../README.md#entity) populated with provided data and a provided entityId. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `id` | `string` | The provided entityId. | +| `entityData` | [`EntityData`](../README.md#entitydata) | The provided entity data. | + +#### Returns + +[`Entity`](../README.md#entity) + +A newly created Entity. + +___ + +### createIndex + +▸ **createIndex**(): `Promise`<`void`\> + +Creates an index in Redis for use by the [search](Repository.md#search) method. +Does not create a new index if the index hasn't changed. Requires that +RediSearch and RedisJSON are installed on your instance of Redis. + +#### Returns + +`Promise`<`void`\> + +___ + +### dropIndex + +▸ **dropIndex**(): `Promise`<`void`\> + +Removes an existing index from Redis. Use this method if you want to swap out your index +because your [Entity](../README.md#entity) has changed. Requires that RediSearch and RedisJSON are installed +on your instance of Redis. + +#### Returns + +`Promise`<`void`\> + +___ + +### expire + +▸ **expire**(`id`, `ttlInSeconds`): `Promise`<`void`\> + +Set the time to live of the [Entity](../README.md#entity). If the [Entity](../README.md#entity) is not +found, does nothing. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `id` | `string` | The ID of the [Entity](../README.md#entity) to set and expiration for. | +| `ttlInSeconds` | `number` | The time to live in seconds. | + +#### Returns + +`Promise`<`void`\> + +▸ **expire**(`ids`, `ttlInSeconds`): `Promise`<`void`\> + +Set the time to live of the [Entities](../README.md#entity) in Redis with the given +ids. If a particular [Entity](../README.md#entity) is not found, does nothing. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `ids` | `string`[] | The IDs of the [Entities](../README.md#entity) you wish to delete. | +| `ttlInSeconds` | `number` | - | + +#### Returns + +`Promise`<`void`\> + +___ + +### fetch + +▸ **fetch**(`id`): `Promise`<[`Entity`](../README.md#entity)\> + +Read and return an [Entity](../README.md#entity) from Redis for the given id. If +the [Entity](../README.md#entity) is not found, returns an empty [Entity](../README.md#entity). + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `id` | `string` | The ID of the [Entity](../README.md#entity) you seek. | + +#### Returns + +`Promise`<[`Entity`](../README.md#entity)\> + +The matching Entity. + +▸ **fetch**(...`ids`): `Promise`<[`Entity`](../README.md#entity)[]\> + +Read and return the [Entities](../README.md#entity) from Redis with the given IDs. If +a particular [Entity](../README.md#entity) is not found, returns that [Entity](../README.md#entity) as empty. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `...ids` | `string`[] | The IDs of the [Entities](../README.md#entity) you seek. | + +#### Returns + +`Promise`<[`Entity`](../README.md#entity)[]\> + +The matching Entities. + +▸ **fetch**(`ids`): `Promise`<[`Entity`](../README.md#entity)[]\> + +Read and return the [Entities](../README.md#entity) from Redis with the given IDs. If +a particular [Entity](../README.md#entity) is not found, returns that [Entity](../README.md#entity) as empty. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `ids` | `string`[] | The IDs of the [Entities](../README.md#entity) you seek. | + +#### Returns + +`Promise`<[`Entity`](../README.md#entity)[]\> + +The matching Entities. + +___ + +### remove + +▸ **remove**(`id`): `Promise`<`void`\> + +Remove an [Entity](../README.md#entity) from Redis for the given id. If the [Entity](../README.md#entity) is +not found, does nothing. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `id` | `string` | The ID of the [Entity](../README.md#entity) you wish to delete. | + +#### Returns + +`Promise`<`void`\> + +▸ **remove**(...`ids`): `Promise`<`void`\> + +Remove the [Entities](../README.md#entity) from Redis for the given ids. If a +particular [Entity](../README.md#entity) is not found, does nothing. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `...ids` | `string`[] | The IDs of the [Entities](../README.md#entity) you wish to delete. | + +#### Returns + +`Promise`<`void`\> + +▸ **remove**(`ids`): `Promise`<`void`\> + +Remove the [Entities](../README.md#entity) from Redis for the given ids. If a +particular [Entity](../README.md#entity) is not found, does nothing. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `ids` | `string`[] | The IDs of the [Entities](../README.md#entity) you wish to delete. | + +#### Returns + +`Promise`<`void`\> + +___ + +### save + +▸ **save**(`entity`): `Promise`<`string`\> + +Insert or update an [Entity](../README.md#entity) to Redis using its entityId property +if present. If it's not, one is generated. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `entity` | [`Entity`](../README.md#entity) | The Entity to save. | + +#### Returns + +`Promise`<`string`\> + +The provided or generated entityId. + +▸ **save**(`id`, `entity`): `Promise`<`string`\> + +Insert or update the [Entity](../README.md#entity) to Redis using the provided entityId. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `id` | `string` | The Entity to save. | +| `entity` | [`Entity`](../README.md#entity) | The Entity to save. | + +#### Returns + +`Promise`<`string`\> + +The provided or generated entityId. + +___ + +### search + +▸ **search**(): [`Search`](Search.md) + +Kicks off the process of building a query. Requires that RediSearch (and optionally +RedisJSON) be installed on your instance of Redis. + +#### Returns + +[`Search`](Search.md) + +A [Search](Search.md) object. + +___ + +### searchRaw + +▸ **searchRaw**(`query`): [`RawSearch`](RawSearch.md) + +Creates a search that bypasses Redis OM and instead allows you to execute a raw +RediSearch query. Requires that RediSearch (and optionally RedisJSON) be installed +on your instance of Redis. + +Refer to https://redis.io/docs/stack/search/reference/query_syntax/ for details on +RediSearch query syntax. + +**`query`** The raw RediSearch query you want to rune. + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `query` | `string` | + +#### Returns + +[`RawSearch`](RawSearch.md) + +A [RawSearch](RawSearch.md) object. diff --git a/docs/classes/Schema.md b/docs/classes/Schema.md new file mode 100644 index 00000000..c887367d --- /dev/null +++ b/docs/classes/Schema.md @@ -0,0 +1,198 @@ +[redis-om](../README.md) / Schema + +# Class: Schema + +Defines a schema that determines how an [Entity](../README.md#entity) is mapped to Redis +data structures. Construct by passing in a prefix for keys in Redis, a +[SchemaDefinition](../README.md#schemadefinition), and optionally [SchemaOptions](../README.md#schemaoptions): + +```typescript +const schema = new Schema('Foo', { + aString: { type: 'string' }, + aNumber: { type: 'number' }, + aBoolean: { type: 'boolean' }, + someText: { type: 'text' }, + aPoint: { type: 'point' }, + aDate: { type: 'date' }, + someStrings: { type: 'string[]' } +}, { + dataStructure: 'HASH' +}) +``` + +A Schema is primarily used by a [Repository](Repository.md) which requires a Schema in +its constructor. + +## Table of contents + +### Constructors + +- [constructor](Schema.md#constructor) + +### Accessors + +- [dataStructure](Schema.md#datastructure) +- [fields](Schema.md#fields) +- [indexHash](Schema.md#indexhash) +- [indexHashName](Schema.md#indexhashname) +- [indexName](Schema.md#indexname) +- [prefix](Schema.md#prefix) +- [stopWords](Schema.md#stopwords) +- [useStopWords](Schema.md#usestopwords) + +### Methods + +- [fieldByName](Schema.md#fieldbyname) +- [generateId](Schema.md#generateid) + +## Constructors + +### constructor + +• **new Schema**(`prefix`, `schemaDef`, `options?`) + +Constructs a Schema. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `prefix` | `string` | The string that comes before the ID when creating Redis keys. | +| `schemaDef` | [`SchemaDefinition`](../README.md#schemadefinition) | Defines all of the fields for the Schema and how they are mapped to Redis. | +| `options?` | [`SchemaOptions`](../README.md#schemaoptions) | Additional options for this Schema. | + +## Accessors + +### dataStructure + +• `get` **dataStructure**(): [`DataStructure`](../README.md#datastructure) + +The configured data structure, a string with the value of either `HASH` or `JSON`, +that this Schema uses to store [Entities](../README.md#entity) in Redis. + +#### Returns + +[`DataStructure`](../README.md#datastructure) + +___ + +### fields + +• `get` **fields**(): [`Field`](Field.md)[] + +The [Fields](Field.md) defined by this Schema. + +#### Returns + +[`Field`](Field.md)[] + +___ + +### indexHash + +• `get` **indexHash**(): `string` + +A hash for this Schema that is used to determine if the Schema has been +changed when calling [createIndex](Repository.md#createindex). + +#### Returns + +`string` + +___ + +### indexHashName + +• `get` **indexHashName**(): `string` + +The configured name for the RediSearch index hash for this Schema. + +#### Returns + +`string` + +___ + +### indexName + +• `get` **indexName**(): `string` + +The configured name for the RediSearch index for this Schema. + +#### Returns + +`string` + +___ + +### prefix + +• `get` **prefix**(): `string` + +The string that comes before the ID when creating Redis keys. Combined +with the results of idStrategy to generate a key. If prefix is `Foo` and +idStrategy returns `12345` then the generated key would be `Foo:12345`. + +#### Returns + +`string` + +___ + +### stopWords + +• `get` **stopWords**(): `string`[] + +The configured stop words. Ignored if [useStopWords](Schema.md#usestopwords) is anything other +than `CUSTOM`. + +#### Returns + +`string`[] + +___ + +### useStopWords + +• `get` **useStopWords**(): [`StopWordOptions`](../README.md#stopwordoptions) + +The configured usage of stop words, a string with the value of either `OFF`, `DEFAULT`, +or `CUSTOM`. See [SchemaOptions](../README.md#schemaoptions) for more details. + +#### Returns + +[`StopWordOptions`](../README.md#stopwordoptions) + +## Methods + +### fieldByName + +▸ **fieldByName**(`name`): [`Field`](Field.md) + +Gets a single [Field](Field.md) defined by this Schema. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `name` | `string` | The name of the [Field](Field.md) in this Schema. | + +#### Returns + +[`Field`](Field.md) + +The [Field](Field.md), or null of not found. + +___ + +### generateId + +▸ **generateId**(): `string` + +Generates a unique string using the configured [IdStrategy](../README.md#idstrategy). + +#### Returns + +`string` + +The generated id. diff --git a/docs/classes/Search.md b/docs/classes/Search.md new file mode 100644 index 00000000..c35db484 --- /dev/null +++ b/docs/classes/Search.md @@ -0,0 +1,1021 @@ +[redis-om](../README.md) / Search + +# Class: Search + +Entry point to fluent search. This is the default Redis OM experience. +Requires that RediSearch (and optionally RedisJSON) be installed. + +**`template`** The type of [Entity](../README.md#entity) being sought. + +## Hierarchy + +- [`AbstractSearch`](AbstractSearch.md) + + ↳ **`Search`** + +## Table of contents + +### Accessors + +- [return](Search.md#return) + +### Methods + +- [all](Search.md#all) +- [allIds](Search.md#allids) +- [allKeys](Search.md#allkeys) +- [and](Search.md#and) +- [count](Search.md#count) +- [first](Search.md#first) +- [firstId](Search.md#firstid) +- [firstKey](Search.md#firstkey) +- [max](Search.md#max) +- [maxId](Search.md#maxid) +- [maxKey](Search.md#maxkey) +- [min](Search.md#min) +- [minId](Search.md#minid) +- [minKey](Search.md#minkey) +- [or](Search.md#or) +- [page](Search.md#page) +- [pageOfIds](Search.md#pageofids) +- [pageOfKeys](Search.md#pageofkeys) +- [returnAll](Search.md#returnall) +- [returnAllIds](Search.md#returnallids) +- [returnAllKeys](Search.md#returnallkeys) +- [returnCount](Search.md#returncount) +- [returnFirst](Search.md#returnfirst) +- [returnFirstId](Search.md#returnfirstid) +- [returnFirstKey](Search.md#returnfirstkey) +- [returnMax](Search.md#returnmax) +- [returnMaxId](Search.md#returnmaxid) +- [returnMaxKey](Search.md#returnmaxkey) +- [returnMin](Search.md#returnmin) +- [returnMinId](Search.md#returnminid) +- [returnMinKey](Search.md#returnminkey) +- [returnPage](Search.md#returnpage) +- [returnPageOfIds](Search.md#returnpageofids) +- [returnPageOfKeys](Search.md#returnpageofkeys) +- [sortAsc](Search.md#sortasc) +- [sortAscending](Search.md#sortascending) +- [sortBy](Search.md#sortby) +- [sortDesc](Search.md#sortdesc) +- [sortDescending](Search.md#sortdescending) +- [where](Search.md#where) + +## Accessors + +### return + +• `get` **return**(): [`AbstractSearch`](AbstractSearch.md) + +Returns the current instance. Syntactic sugar to make your code more fluent. + +#### Returns + +[`AbstractSearch`](AbstractSearch.md) + +this + +#### Inherited from + +AbstractSearch.return + +## Methods + +### all + +▸ **all**(`options?`): `Promise`<[`Entity`](../README.md#entity)[]\> + +Returns all the [Entities](../README.md#entity) that match this query. This method +makes multiple calls to Redis until all the [Entities](../README.md#entity) are returned. +You can specify the batch size by setting the `pageSize` property on the +options: + +```typescript +const entities = await repository.search().returnAll({ pageSize: 100 }) +``` + +#### Parameters + +| Name | Type | Default value | Description | +| :------ | :------ | :------ | :------ | +| `options` | `Object` | `undefined` | Options for the call. | +| `options.pageSize` | `number` | `10` | Number of [Entities](../README.md#entity) returned per batch. | + +#### Returns + +`Promise`<[`Entity`](../README.md#entity)[]\> + +An array of [Entities](../README.md#entity) matching the query. + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[all](AbstractSearch.md#all) + +___ + +### allIds + +▸ **allIds**(`options?`): `Promise`<`string`[]\> + +Returns all the entity IDs that match this query. This method +makes multiple calls to Redis until all the entity IDs are returned. +You can specify the batch size by setting the `pageSize` property on the +options: + +```typescript +const keys = await repository.search().returnAllIds({ pageSize: 100 }) +``` + +#### Parameters + +| Name | Type | Default value | Description | +| :------ | :------ | :------ | :------ | +| `options` | `Object` | `undefined` | Options for the call. | +| `options.pageSize` | `number` | `10` | Number of entity IDs returned per batch. | + +#### Returns + +`Promise`<`string`[]\> + +An array of entity IDs matching the query. + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[allIds](AbstractSearch.md#allids) + +___ + +### allKeys + +▸ **allKeys**(`options?`): `Promise`<`string`[]\> + +Returns all the key names in Redis that match this query. This method +makes multiple calls to Redis until all the key names are returned. +You can specify the batch size by setting the `pageSize` property on the +options: + +```typescript +const keys = await repository.search().returnAllKeys({ pageSize: 100 }) +``` + +#### Parameters + +| Name | Type | Default value | Description | +| :------ | :------ | :------ | :------ | +| `options` | `Object` | `undefined` | Options for the call. | +| `options.pageSize` | `number` | `10` | Number of key names returned per batch. | + +#### Returns + +`Promise`<`string`[]\> + +An array of key names matching the query. + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[allKeys](AbstractSearch.md#allkeys) + +___ + +### and + +▸ **and**(`field`): [`WhereField`](WhereField.md) + +Sets up a query matching a particular field as a logical AND. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `field` | `string` | The field to filter on. | + +#### Returns + +[`WhereField`](WhereField.md) + +A subclass of [WhereField](WhereField.md) matching the type of the field. + +▸ **and**(`subSearchFn`): [`Search`](Search.md) + +Sets up a nested search as a logical AND. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `subSearchFn` | [`SubSearchFunction`](../README.md#subsearchfunction) | A function that takes a [Search](Search.md) and returns another [Search](Search.md). | + +#### Returns + +[`Search`](Search.md) + +`this`. + +___ + +### count + +▸ **count**(): `Promise`<`number`\> + +Returns the number of [Entities](../README.md#entity) that match this query. + +#### Returns + +`Promise`<`number`\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[count](AbstractSearch.md#count) + +___ + +### first + +▸ **first**(): `Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +Returns the first [Entity](../README.md#entity) that matches this query. + +#### Returns + +`Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[first](AbstractSearch.md#first) + +___ + +### firstId + +▸ **firstId**(): `Promise`<``null`` \| `string`\> + +Returns the first entity ID that matches this query. + +#### Returns + +`Promise`<``null`` \| `string`\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[firstId](AbstractSearch.md#firstid) + +___ + +### firstKey + +▸ **firstKey**(): `Promise`<``null`` \| `string`\> + +Returns the first key name that matches this query. + +#### Returns + +`Promise`<``null`` \| `string`\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[firstKey](AbstractSearch.md#firstkey) + +___ + +### max + +▸ **max**(`field`): `Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +Finds the [Entity](../README.md#entity) with the maximal value for a field. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `field` | `string` | The field with the maximal value. | + +#### Returns + +`Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +The entity ID [Entity](../README.md#entity) with the maximal value + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[max](AbstractSearch.md#max) + +___ + +### maxId + +▸ **maxId**(`field`): `Promise`<``null`` \| `string`\> + +Finds the entity ID with the maximal value for a field. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `field` | `string` | The field with the maximal value. | + +#### Returns + +`Promise`<``null`` \| `string`\> + +The entity ID with the maximal value + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[maxId](AbstractSearch.md#maxid) + +___ + +### maxKey + +▸ **maxKey**(`field`): `Promise`<``null`` \| `string`\> + +Finds the key name in Redis with the maximal value for a field. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `field` | `string` | The field with the maximal value. | + +#### Returns + +`Promise`<``null`` \| `string`\> + +The key name with the maximal value + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[maxKey](AbstractSearch.md#maxkey) + +___ + +### min + +▸ **min**(`field`): `Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +Finds the [Entity](../README.md#entity) with the minimal value for a field. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `field` | `string` | The field with the minimal value. | + +#### Returns + +`Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +The [Entity](../README.md#entity) with the minimal value + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[min](AbstractSearch.md#min) + +___ + +### minId + +▸ **minId**(`field`): `Promise`<``null`` \| `string`\> + +Finds the entity ID with the minimal value for a field. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `field` | `string` | The field with the minimal value. | + +#### Returns + +`Promise`<``null`` \| `string`\> + +The entity ID with the minimal value + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[minId](AbstractSearch.md#minid) + +___ + +### minKey + +▸ **minKey**(`field`): `Promise`<``null`` \| `string`\> + +Finds the key name in Redis with the minimal value for a field. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `field` | `string` | The field with the minimal value. | + +#### Returns + +`Promise`<``null`` \| `string`\> + +The key name with the minimal value + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[minKey](AbstractSearch.md#minkey) + +___ + +### or + +▸ **or**(`field`): [`WhereField`](WhereField.md) + +Sets up a query matching a particular field as a logical OR. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `field` | `string` | The field to filter on. | + +#### Returns + +[`WhereField`](WhereField.md) + +A subclass of [WhereField](WhereField.md) matching the type of the field. + +▸ **or**(`subSearchFn`): [`Search`](Search.md) + +Sets up a nested search as a logical OR. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `subSearchFn` | [`SubSearchFunction`](../README.md#subsearchfunction) | A function that takes a [Search](Search.md) and returns another [Search](Search.md). | + +#### Returns + +[`Search`](Search.md) + +`this`. + +___ + +### page + +▸ **page**(`offset`, `count`): `Promise`<[`Entity`](../README.md#entity)[]\> + +Returns a page of [Entities](../README.md#entity) that match this query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `offset` | `number` | The offset for where to start returning [Entities](../README.md#entity). | +| `count` | `number` | The number of [Entities](../README.md#entity) to return. | + +#### Returns + +`Promise`<[`Entity`](../README.md#entity)[]\> + +An array of [Entities](../README.md#entity) matching the query. + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[page](AbstractSearch.md#page) + +___ + +### pageOfIds + +▸ **pageOfIds**(`offset`, `count`): `Promise`<`string`[]\> + +Returns a page of entity IDs that match this query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `offset` | `number` | The offset for where to start returning entity IDs. | +| `count` | `number` | The number of entity IDs to return. | + +#### Returns + +`Promise`<`string`[]\> + +An array of strings matching the query. + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[pageOfIds](AbstractSearch.md#pageofids) + +___ + +### pageOfKeys + +▸ **pageOfKeys**(`offset`, `count`): `Promise`<`string`[]\> + +Returns a page of key names in Redis that match this query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `offset` | `number` | The offset for where to start returning key names. | +| `count` | `number` | The number of key names to return. | + +#### Returns + +`Promise`<`string`[]\> + +An array of strings matching the query. + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[pageOfKeys](AbstractSearch.md#pageofkeys) + +___ + +### returnAll + +▸ **returnAll**(`options?`): `Promise`<[`Entity`](../README.md#entity)[]\> + +Alias for [all](Search.md#all). + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `options` | `Object` | `undefined` | +| `options.pageSize` | `number` | `10` | + +#### Returns + +`Promise`<[`Entity`](../README.md#entity)[]\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnAll](AbstractSearch.md#returnall) + +___ + +### returnAllIds + +▸ **returnAllIds**(`options?`): `Promise`<`string`[]\> + +Alias for [allIds](Search.md#allids). + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `options` | `Object` | `undefined` | +| `options.pageSize` | `number` | `10` | + +#### Returns + +`Promise`<`string`[]\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnAllIds](AbstractSearch.md#returnallids) + +___ + +### returnAllKeys + +▸ **returnAllKeys**(`options?`): `Promise`<`string`[]\> + +Alias for [allKeys](Search.md#allkeys). + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `options` | `Object` | `undefined` | +| `options.pageSize` | `number` | `10` | + +#### Returns + +`Promise`<`string`[]\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnAllKeys](AbstractSearch.md#returnallkeys) + +___ + +### returnCount + +▸ **returnCount**(): `Promise`<`number`\> + +Alias for [count](Search.md#count). + +#### Returns + +`Promise`<`number`\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnCount](AbstractSearch.md#returncount) + +___ + +### returnFirst + +▸ **returnFirst**(): `Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +Alias for [first](Search.md#first). + +#### Returns + +`Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnFirst](AbstractSearch.md#returnfirst) + +___ + +### returnFirstId + +▸ **returnFirstId**(): `Promise`<``null`` \| `string`\> + +Alias for [firstId](Search.md#firstid). + +#### Returns + +`Promise`<``null`` \| `string`\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnFirstId](AbstractSearch.md#returnfirstid) + +___ + +### returnFirstKey + +▸ **returnFirstKey**(): `Promise`<``null`` \| `string`\> + +Alias for [firstKey](Search.md#firstkey). + +#### Returns + +`Promise`<``null`` \| `string`\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnFirstKey](AbstractSearch.md#returnfirstkey) + +___ + +### returnMax + +▸ **returnMax**(`field`): `Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +Alias for [max](Search.md#max). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `field` | `string` | + +#### Returns + +`Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnMax](AbstractSearch.md#returnmax) + +___ + +### returnMaxId + +▸ **returnMaxId**(`field`): `Promise`<``null`` \| `string`\> + +Alias for [maxId](Search.md#maxid). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `field` | `string` | + +#### Returns + +`Promise`<``null`` \| `string`\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnMaxId](AbstractSearch.md#returnmaxid) + +___ + +### returnMaxKey + +▸ **returnMaxKey**(`field`): `Promise`<``null`` \| `string`\> + +Alias for [maxKey](Search.md#maxkey). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `field` | `string` | + +#### Returns + +`Promise`<``null`` \| `string`\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnMaxKey](AbstractSearch.md#returnmaxkey) + +___ + +### returnMin + +▸ **returnMin**(`field`): `Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +Alias for [min](Search.md#min). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `field` | `string` | + +#### Returns + +`Promise`<``null`` \| [`Entity`](../README.md#entity)\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnMin](AbstractSearch.md#returnmin) + +___ + +### returnMinId + +▸ **returnMinId**(`field`): `Promise`<``null`` \| `string`\> + +Alias for [minId](Search.md#minid). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `field` | `string` | + +#### Returns + +`Promise`<``null`` \| `string`\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnMinId](AbstractSearch.md#returnminid) + +___ + +### returnMinKey + +▸ **returnMinKey**(`field`): `Promise`<``null`` \| `string`\> + +Alias for [minKey](Search.md#minkey). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `field` | `string` | + +#### Returns + +`Promise`<``null`` \| `string`\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnMinKey](AbstractSearch.md#returnminkey) + +___ + +### returnPage + +▸ **returnPage**(`offset`, `count`): `Promise`<[`Entity`](../README.md#entity)[]\> + +Alias for [page](Search.md#page). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `offset` | `number` | +| `count` | `number` | + +#### Returns + +`Promise`<[`Entity`](../README.md#entity)[]\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnPage](AbstractSearch.md#returnpage) + +___ + +### returnPageOfIds + +▸ **returnPageOfIds**(`offset`, `count`): `Promise`<`string`[]\> + +Alias for [pageOfIds](Search.md#pageofids). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `offset` | `number` | +| `count` | `number` | + +#### Returns + +`Promise`<`string`[]\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnPageOfIds](AbstractSearch.md#returnpageofids) + +___ + +### returnPageOfKeys + +▸ **returnPageOfKeys**(`offset`, `count`): `Promise`<`string`[]\> + +Alias for [pageOfKeys](Search.md#pageofkeys). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `offset` | `number` | +| `count` | `number` | + +#### Returns + +`Promise`<`string`[]\> + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[returnPageOfKeys](AbstractSearch.md#returnpageofkeys) + +___ + +### sortAsc + +▸ **sortAsc**(`field`): [`AbstractSearch`](AbstractSearch.md) + +Alias for [sortAscending](Search.md#sortascending). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `field` | `string` | + +#### Returns + +[`AbstractSearch`](AbstractSearch.md) + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[sortAsc](AbstractSearch.md#sortasc) + +___ + +### sortAscending + +▸ **sortAscending**(`field`): [`AbstractSearch`](AbstractSearch.md) + +Applies an ascending sort to the query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `field` | `string` | The field to sort by. | + +#### Returns + +[`AbstractSearch`](AbstractSearch.md) + +this + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[sortAscending](AbstractSearch.md#sortascending) + +___ + +### sortBy + +▸ **sortBy**(`fieldName`, `order?`): [`AbstractSearch`](AbstractSearch.md) + +Applies sorting for the query. + +#### Parameters + +| Name | Type | Default value | Description | +| :------ | :------ | :------ | :------ | +| `fieldName` | `string` | `undefined` | - | +| `order` | ``"ASC"`` \| ``"DESC"`` | `'ASC'` | The order of returned [Entities](../README.md#entity) Defaults to `ASC` (ascending) if not specified | + +#### Returns + +[`AbstractSearch`](AbstractSearch.md) + +this + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[sortBy](AbstractSearch.md#sortby) + +___ + +### sortDesc + +▸ **sortDesc**(`field`): [`AbstractSearch`](AbstractSearch.md) + +Alias for [sortDescending](Search.md#sortdescending). + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `field` | `string` | + +#### Returns + +[`AbstractSearch`](AbstractSearch.md) + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[sortDesc](AbstractSearch.md#sortdesc) + +___ + +### sortDescending + +▸ **sortDescending**(`field`): [`AbstractSearch`](AbstractSearch.md) + +Applies a descending sort to the query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `field` | `string` | The field to sort by. | + +#### Returns + +[`AbstractSearch`](AbstractSearch.md) + +this + +#### Inherited from + +[AbstractSearch](AbstractSearch.md).[sortDescending](AbstractSearch.md#sortdescending) + +___ + +### where + +▸ **where**(`field`): [`WhereField`](WhereField.md) + +Sets up a query matching a particular field. If there are multiple calls +to [where](Search.md#where), they are treated logically as AND. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `field` | `string` | The field to filter on. | + +#### Returns + +[`WhereField`](WhereField.md) + +A subclass of [WhereField](WhereField.md) matching the type of the field. + +▸ **where**(`subSearchFn`): [`Search`](Search.md) + +Sets up a nested search. If there are multiple calls to [where](Search.md#where), +they are treated logically as AND. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `subSearchFn` | [`SubSearchFunction`](../README.md#subsearchfunction) | A function that takes a [Search](Search.md) and returns another [Search](Search.md). | + +#### Returns + +[`Search`](Search.md) + +`this`. diff --git a/docs/classes/Where.md b/docs/classes/Where.md new file mode 100644 index 00000000..44bcf814 --- /dev/null +++ b/docs/classes/Where.md @@ -0,0 +1,39 @@ +[redis-om](../README.md) / Where + +# Class: Where + +Abstract base class used extensively with [Search](Search.md). + +## Hierarchy + +- **`Where`** + + ↳ [`WhereField`](WhereField.md) + +## Table of contents + +### Constructors + +- [constructor](Where.md#constructor) + +### Methods + +- [toString](Where.md#tostring) + +## Constructors + +### constructor + +• **new Where**() + +## Methods + +### toString + +▸ `Abstract` **toString**(): `string` + +Converts this [Where](Where.md) into a portion of a RediSearch query. + +#### Returns + +`string` diff --git a/docs/classes/WhereField.md b/docs/classes/WhereField.md new file mode 100644 index 00000000..023f7406 --- /dev/null +++ b/docs/classes/WhereField.md @@ -0,0 +1,769 @@ +[redis-om](../README.md) / WhereField + +# Class: WhereField + +Abstract base class that all fields you want to filter +with extend. When you call [where](Search.md#where), a +subclass of this is returned. + +## Hierarchy + +- [`Where`](Where.md) + + ↳ **`WhereField`** + +## Table of contents + +### Properties + +- [exact](WhereField.md#exact) +- [exactly](WhereField.md#exactly) + +### Accessors + +- [does](WhereField.md#does) +- [is](WhereField.md#is) +- [not](WhereField.md#not) + +### Methods + +- [after](WhereField.md#after) +- [before](WhereField.md#before) +- [between](WhereField.md#between) +- [contain](WhereField.md#contain) +- [containOneOf](WhereField.md#containoneof) +- [contains](WhereField.md#contains) +- [containsOneOf](WhereField.md#containsoneof) +- [eq](WhereField.md#eq) +- [equal](WhereField.md#equal) +- [equalTo](WhereField.md#equalto) +- [equals](WhereField.md#equals) +- [false](WhereField.md#false) +- [greaterThan](WhereField.md#greaterthan) +- [greaterThanOrEqualTo](WhereField.md#greaterthanorequalto) +- [gt](WhereField.md#gt) +- [gte](WhereField.md#gte) +- [inCircle](WhereField.md#incircle) +- [inRadius](WhereField.md#inradius) +- [lessThan](WhereField.md#lessthan) +- [lessThanOrEqualTo](WhereField.md#lessthanorequalto) +- [lt](WhereField.md#lt) +- [lte](WhereField.md#lte) +- [match](WhereField.md#match) +- [matchExact](WhereField.md#matchexact) +- [matchExactly](WhereField.md#matchexactly) +- [matches](WhereField.md#matches) +- [matchesExactly](WhereField.md#matchesexactly) +- [on](WhereField.md#on) +- [onOrAfter](WhereField.md#onorafter) +- [onOrBefore](WhereField.md#onorbefore) +- [toString](WhereField.md#tostring) +- [true](WhereField.md#true) + +## Properties + +### exact + +• `Readonly` **exact**: [`WhereField`](WhereField.md) + +Makes a call to [match](WhereField.md#match) a [matchExact](WhereField.md#matchexact) call. Calling +this multiple times will have no effect. + +#### Defined in + +[lib/search/where-field.ts:92](https://github.com/redis/redis-om-node/blob/61aae69/lib/search/where-field.ts#L92) + +___ + +### exactly + +• `Readonly` **exactly**: [`WhereField`](WhereField.md) + +Makes a call to [match](WhereField.md#match) a [matchExact](WhereField.md#matchexact) call. Calling +this multiple times will have no effect. + +#### Defined in + +[lib/search/where-field.ts:99](https://github.com/redis/redis-om-node/blob/61aae69/lib/search/where-field.ts#L99) + +## Accessors + +### does + +• `get` **does**(): `this` + +Returns the current instance. Syntactic sugar to make your code more fluent. + +#### Returns + +`this` + +this + +___ + +### is + +• `get` **is**(): `this` + +Returns the current instance. Syntactic sugar to make your code more fluent. + +#### Returns + +`this` + +this + +___ + +### not + +• `get` **not**(): `this` + +Negates the query on the field, cause it to match when the condition is +*not* met. Calling this multiple times will negate the negation. + +#### Returns + +`this` + +this + +## Methods + +### after + +▸ **after**(`value`): [`Search`](Search.md) + +Add a search that matches all datetimes *after* the provided UTC datetime to the query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `value` | `string` \| `number` \| `Date` | The datetime to compare against. | + +#### Returns + +[`Search`](Search.md) + +The [Search](Search.md) that was called to create this [WhereField](WhereField.md). + +___ + +### before + +▸ **before**(`value`): [`Search`](Search.md) + +Add a search that matches all datetimes *before* the provided UTC datetime to the query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `value` | `string` \| `number` \| `Date` | The datetime to compare against. | + +#### Returns + +[`Search`](Search.md) + +The [Search](Search.md) that was called to create this [WhereField](WhereField.md). + +___ + +### between + +▸ **between**(`lower`, `upper`): [`Search`](Search.md) + +Adds an inclusive range comparison against a field to the search query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `lower` | `string` \| `number` \| `Date` | The lower bound of the range. | +| `upper` | `string` \| `number` \| `Date` | The upper bound of the range. | + +#### Returns + +[`Search`](Search.md) + +The [Search](Search.md) that was called to create this [WhereField](WhereField.md). + +___ + +### contain + +▸ **contain**(`value`): [`Search`](Search.md) + +Adds a whole-string match for a value within a string array to the search query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `value` | `string` | The string to be matched. | + +#### Returns + +[`Search`](Search.md) + +The [Search](Search.md) that was called to create this [WhereField](WhereField.md). + +___ + +### containOneOf + +▸ **containOneOf**(...`value`): [`Search`](Search.md) + +Adds a whole-string match against a string array to the query. If any of the provided +strings in `value` is matched in the array, this matched. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `...value` | `string`[] | An array of strings that you want to match one of. | + +#### Returns + +[`Search`](Search.md) + +The [Search](Search.md) that was called to create this [WhereField](WhereField.md). + +___ + +### contains + +▸ **contains**(`value`): [`Search`](Search.md) + +Adds a whole-string match for a value within a string array to the search query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `value` | `string` | The string to be matched. | + +#### Returns + +[`Search`](Search.md) + +The [Search](Search.md) that was called to create this [WhereField](WhereField.md). + +___ + +### containsOneOf + +▸ **containsOneOf**(...`value`): [`Search`](Search.md) + +Adds a whole-string match against a string array to the query. If any of the provided +strings in `value` is matched in the array, this matched. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `...value` | `string`[] | An array of strings that you want to match one of. | + +#### Returns + +[`Search`](Search.md) + +The [Search](Search.md) that was called to create this [WhereField](WhereField.md). + +___ + +### eq + +▸ **eq**(`value`): [`Search`](Search.md) + +Adds an equals comparison to the query. + +NOTE: this function is not available for strings where full-text +search is enabled. In that scenario, use `.match`. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `value` | `string` \| `number` \| `boolean` \| `Date` | The value to be compared | + +#### Returns + +[`Search`](Search.md) + +The [Search](Search.md) that was called to create this [WhereField](WhereField.md). + +___ + +### equal + +▸ **equal**(`value`): [`Search`](Search.md) + +Adds an equals comparison to the query. + +NOTE: this function is not available for strings where full-text +search is enabled. In that scenario, use `.match`. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `value` | `string` \| `number` \| `boolean` \| `Date` | The value to be compared | + +#### Returns + +[`Search`](Search.md) + +The [Search](Search.md) that was called to create this [WhereField](WhereField.md). + +___ + +### equalTo + +▸ **equalTo**(`value`): [`Search`](Search.md) + +Adds an equals comparison to the query. + +NOTE: this function is not available for strings where full-text +search is enabled. In that scenario, use `.match`. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `value` | `string` \| `number` \| `boolean` \| `Date` | The value to be compared | + +#### Returns + +[`Search`](Search.md) + +The [Search](Search.md) that was called to create this [WhereField](WhereField.md). + +___ + +### equals + +▸ **equals**(`value`): [`Search`](Search.md) + +Adds an equals comparison to the query. + +NOTE: this function is not available for strings where full-text +search is enabled. In that scenario, use `.match`. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `value` | `string` \| `number` \| `boolean` \| `Date` | The value to be compared | + +#### Returns + +[`Search`](Search.md) + +The [Search](Search.md) that was called to create this [WhereField](WhereField.md). + +___ + +### false + +▸ **false**(): [`Search`](Search.md) + +Adds a boolean match with a value of `false` to the query. + +#### Returns + +[`Search`](Search.md) + +The [Search](Search.md) that was called to create this [WhereField](WhereField.md). + +___ + +### greaterThan + +▸ **greaterThan**(`value`): [`Search`](Search.md) + +Adds a greater than comparison against a field to the search query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `value` | `string` \| `number` \| `Date` | The value to compare against. | + +#### Returns + +[`Search`](Search.md) + +The [Search](Search.md) that was called to create this [WhereField](WhereField.md). + +___ + +### greaterThanOrEqualTo + +▸ **greaterThanOrEqualTo**(`value`): [`Search`](Search.md) + +Adds a greater than or equal to comparison against a field to the search query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `value` | `string` \| `number` \| `Date` | The value to compare against. | + +#### Returns + +[`Search`](Search.md) + +The [Search](Search.md) that was called to create this [WhereField](WhereField.md). + +___ + +### gt + +▸ **gt**(`value`): [`Search`](Search.md) + +Adds a greater than comparison against a field to the search query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `value` | `string` \| `number` \| `Date` | The value to compare against. | + +#### Returns + +[`Search`](Search.md) + +The [Search](Search.md) that was called to create this [WhereField](WhereField.md). + +___ + +### gte + +▸ **gte**(`value`): [`Search`](Search.md) + +Adds a greater than or equal to comparison against a field to the search query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `value` | `string` \| `number` \| `Date` | The value to compare against. | + +#### Returns + +[`Search`](Search.md) + +The [Search](Search.md) that was called to create this [WhereField](WhereField.md). + +___ + +### inCircle + +▸ **inCircle**(`circleFn`): [`Search`](Search.md) + +Adds a search for points that fall within a defined circle. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `circleFn` | [`CircleFunction`](../README.md#circlefunction) | A function that returns a [Circle](Circle.md) instance defining the search area. | + +#### Returns + +[`Search`](Search.md) + +The [Search](Search.md) that was called to create this [WhereField](WhereField.md). + +___ + +### inRadius + +▸ **inRadius**(`circleFn`): [`Search`](Search.md) + +Adds a search for points that fall within a defined radius. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `circleFn` | [`CircleFunction`](../README.md#circlefunction) | A function that returns a [Circle](Circle.md) instance defining the search area. | + +#### Returns + +[`Search`](Search.md) + +The [Search](Search.md) that was called to create this [WhereField](WhereField.md). + +___ + +### lessThan + +▸ **lessThan**(`value`): [`Search`](Search.md) + +Adds a less than comparison against a field to the search query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `value` | `string` \| `number` \| `Date` | The value to compare against. | + +#### Returns + +[`Search`](Search.md) + +The [Search](Search.md) that was called to create this [WhereField](WhereField.md). + +___ + +### lessThanOrEqualTo + +▸ **lessThanOrEqualTo**(`value`): [`Search`](Search.md) + +Adds a less than or equal to comparison against a field to the search query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `value` | `string` \| `number` \| `Date` | The value to compare against. | + +#### Returns + +[`Search`](Search.md) + +The [Search](Search.md) that was called to create this [WhereField](WhereField.md). + +___ + +### lt + +▸ **lt**(`value`): [`Search`](Search.md) + +Adds a less than comparison against a field to the search query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `value` | `string` \| `number` \| `Date` | The value to compare against. | + +#### Returns + +[`Search`](Search.md) + +The [Search](Search.md) that was called to create this [WhereField](WhereField.md). + +___ + +### lte + +▸ **lte**(`value`): [`Search`](Search.md) + +Adds a less than or equal to comparison against a field to the search query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `value` | `string` \| `number` \| `Date` | The value to compare against. | + +#### Returns + +[`Search`](Search.md) + +The [Search](Search.md) that was called to create this [WhereField](WhereField.md). + +___ + +### match + +▸ **match**(`value`): [`Search`](Search.md) + +Adds a full-text search comparison to the query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `value` | `string` \| `number` \| `boolean` | The word or phrase sought. | + +#### Returns + +[`Search`](Search.md) + +The [Search](Search.md) that was called to create this [WhereField](WhereField.md). + +___ + +### matchExact + +▸ **matchExact**(`value`): [`Search`](Search.md) + +Adds a full-text search comparison to the query that matches an exact word or phrase. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `value` | `string` \| `number` \| `boolean` | The word or phrase sought. | + +#### Returns + +[`Search`](Search.md) + +The [Search](Search.md) that was called to create this [WhereField](WhereField.md). + +___ + +### matchExactly + +▸ **matchExactly**(`value`): [`Search`](Search.md) + +Adds a full-text search comparison to the query that matches an exact word or phrase. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `value` | `string` \| `number` \| `boolean` | The word or phrase sought. | + +#### Returns + +[`Search`](Search.md) + +The [Search](Search.md) that was called to create this [WhereField](WhereField.md). + +___ + +### matches + +▸ **matches**(`value`): [`Search`](Search.md) + +Adds a full-text search comparison to the query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `value` | `string` \| `number` \| `boolean` | The word or phrase sought. | + +#### Returns + +[`Search`](Search.md) + +The [Search](Search.md) that was called to create this [WhereField](WhereField.md). + +___ + +### matchesExactly + +▸ **matchesExactly**(`value`): [`Search`](Search.md) + +Adds a full-text search comparison to the query that matches an exact word or phrase. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `value` | `string` \| `number` \| `boolean` | The word or phrase sought. | + +#### Returns + +[`Search`](Search.md) + +The [Search](Search.md) that was called to create this [WhereField](WhereField.md). + +___ + +### on + +▸ **on**(`value`): [`Search`](Search.md) + +Add a search for an exact UTC datetime to the query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `value` | `string` \| `number` \| `Date` | The datetime to match. | + +#### Returns + +[`Search`](Search.md) + +The [Search](Search.md) that was called to create this [WhereField](WhereField.md). + +___ + +### onOrAfter + +▸ **onOrAfter**(`value`): [`Search`](Search.md) + +Add a search that matches all datetimes *on or after* the provided UTC datetime to the query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `value` | `string` \| `number` \| `Date` | The datetime to compare against. | + +#### Returns + +[`Search`](Search.md) + +The [Search](Search.md) that was called to create this [WhereField](WhereField.md). + +___ + +### onOrBefore + +▸ **onOrBefore**(`value`): [`Search`](Search.md) + +Add a search that matches all datetimes *on or before* the provided UTC datetime to the query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `value` | `string` \| `number` \| `Date` | The datetime to compare against. | + +#### Returns + +[`Search`](Search.md) + +The [Search](Search.md) that was called to create this [WhereField](WhereField.md). + +___ + +### toString + +▸ `Abstract` **toString**(): `string` + +Converts this [Where](Where.md) into a portion of a RediSearch query. + +#### Returns + +`string` + +#### Inherited from + +[Where](Where.md).[toString](Where.md#tostring) + +___ + +### true + +▸ **true**(): [`Search`](Search.md) + +Adds a boolean match with a value of `true` to the query. + +#### Returns + +[`Search`](Search.md) + +The [Search](Search.md) that was called to create this [WhereField](WhereField.md). diff --git a/package.json b/package.json index 48195770..7782df37 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "redis-om", - "version": "0.3.6", + "version": "0.4.0", "description": "Object mapping, and more, for Redis and Node.js. Written in TypeScript.", "main": "dist/index.js", "types": "./dist/index.d.ts",