Skip to content

Commit

Permalink
adjusted version, corrected and updated README, removed a bit of dead…
Browse files Browse the repository at this point in the history
… code, rebuild docs
  • Loading branch information
guyroyse committed Apr 28, 2022
1 parent 9708a58 commit e5ab2ab
Show file tree
Hide file tree
Showing 40 changed files with 894 additions and 1,171 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v12
v14.8
13 changes: 13 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@

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

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


## 0.2.1 - 2022-03-30
### Added
- Added limited ability to sort search results using `.sortBy`.
Expand Down
57 changes: 25 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,23 +142,19 @@ You connect to Redis using a [*client*](docs/classes/Client.md). The `Client` cl
```javascript
import { Client } from 'redis-om'

(async function() {
const client = new Client()
await client.open('redis://localhost:6379')

const client = new Client()
await client.open('redis://localhost:6379')
const aString = await client.execute(['PING'])
// 'PONG'

const aString = await client.execute(['PING'])
// 'PONG'
const aNumber = await client.execute(['HSET', 'foo', 'bar', 'baz', 'qux', 42])
// 2

const aNumber = await client.execute(['HSET', 'foo', 'bar', 'baz', 'qux', 42])
// 2
const anArray = await client.execute(['HGETALL', 'foo'])
// [ 'bar', 'baz', 'qux', '42' ]

const anArray = await client.execute(['HGETALL', 'foo'])
// [ 'bar', 'baz', 'qux', '42' ]

await client.close()

})()
await client.close()
```

<details>
Expand All @@ -169,19 +165,18 @@ Typecasts can be done in 2 ways, casting it before the returning value `client.e

```typescript
import { Client } from 'redis-om';
(async () => {
let client = await new Client().open('redis://localhost:6379');

let aString = await <string>client.execute(['PING']);
// 'PONG'
let client = await new Client().open('redis://localhost:6379');

let aString = await <string>client.execute(['PING']);
// 'PONG'

let aNumber = await <number>client.execute(['HSET', 'foo', 'bar', 'baz', 'qux', 42]);
// 2
let aNumber = await <number>client.execute(['HSET', 'foo', 'bar', 'baz', 'qux', 42]);
// 2

let anArray = await <Array<string>>client.execute(['HGETALL', 'foo']);
// [ 'bar', 'baz', 'qux', '42' ]
await client.close();
})();
let anArray = await <Array<string>>client.execute(['HGETALL', 'foo']);
// [ 'bar', 'baz', 'qux', '42' ]
await client.close();
```
</details>

Expand All @@ -193,14 +188,12 @@ If you find you need to talk to Redis directly a *lot* or you need more than jus
import { createClient } from 'redis'
import { Client } from 'redis-om'

(async function() {
const redis = createClient('redis://localhost:6379')
await redis.connect()
const client = await new Client().use(redis)

const redis = createClient('redis://localhost:6379')
const client = await new Client().use(redis)

await redis.set('foo', 'bar')
const value = await client.execute(['GET', 'foo'])
})()
await redis.set('foo', 'bar')
const value = await client.execute(['GET', 'foo'])
```

Use `.use` to take advantage of things like [clustering](https://github.com/redis/node-redis#clustering). Details on all that stuff are way beyond the scope of this README. You can read about it in the Node Redis [documentation](https://github.com/redis/node-redis).
Expand Down Expand Up @@ -736,7 +729,7 @@ studios = await studioRepository.search().where('established').not.gt(date).retu
studios = await studioRepository.search().where('established').greaterThan(date).return.all()
studios = await studioRepository.search().where('established').is.greaterThan(date).return.all()
studios = await studioRepository.search().where('established').is.not.greaterThan(date).return.all()

studios = await studioRepository.search().where('established').gte(date).return.all()
studios = await studioRepository.search().where('established').not.gte(date).return.all()
studios = await studioRepository.search().where('established').greaterThanOrEqualTo(date).return.all()
Expand All @@ -748,7 +741,7 @@ studios = await studioRepository.search().where('established').not.lt(date).retu
studios = await studioRepository.search().where('established').lessThan(date).return.all()
studios = await studioRepository.search().where('established').is.lessThan(date).return.all()
studios = await studioRepository.search().where('established').is.not.lessThan(date).return.all()

studios = await studioRepository.search().where('established').lte(date).return.all()
studios = await studioRepository.search().where('established').not.lte(date).return.all()
studios = await studioRepository.search().where('established').lessThanOrEqualTo(date).return.all()
Expand Down
92 changes: 52 additions & 40 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,29 @@ redis-om

### Interfaces

- [BooleanField](interfaces/BooleanField.md)
- [DateField](interfaces/DateField.md)
- [Field](interfaces/Field.md)
- [NumberField](interfaces/NumberField.md)
- [PointField](interfaces/PointField.md)
- [Separable](interfaces/Separable.md)
- [Sortable](interfaces/Sortable.md)
- [StringArrayField](interfaces/StringArrayField.md)
- [StringField](interfaces/StringField.md)
- [TextField](interfaces/TextField.md)
- [BaseFieldDefinition](interfaces/BaseFieldDefinition.md)
- [BooleanFieldDefinition](interfaces/BooleanFieldDefinition.md)
- [DateFieldDefinition](interfaces/DateFieldDefinition.md)
- [NumberFieldDefinition](interfaces/NumberFieldDefinition.md)
- [PointFieldDefinition](interfaces/PointFieldDefinition.md)
- [SeparableFieldDefinition](interfaces/SeparableFieldDefinition.md)
- [SortableFieldDefinition](interfaces/SortableFieldDefinition.md)
- [StringArrayFieldDefinition](interfaces/StringArrayFieldDefinition.md)
- [StringFieldDefinition](interfaces/StringFieldDefinition.md)
- [TextFieldDefinition](interfaces/TextFieldDefinition.md)

### Type aliases

- [CircleFunction](README.md#circlefunction)
- [DataStructure](README.md#datastructure)
- [EntityConstructor](README.md#entityconstructor)
- [EntityCreationData](README.md#entitycreationdata)
- [EntityData](README.md#entitydata)
- [EntityValue](README.md#entityvalue)
- [FieldDefinition](README.md#fielddefinition)
- [IdStrategy](README.md#idstrategy)
- [Point](README.md#point)
- [SchemaDefinition](README.md#schemadefinition)
- [SchemaFieldType](README.md#schemafieldtype)
- [SchemaOptions](README.md#schemaoptions)
- [SearchDataStructure](README.md#searchdatastructure)
- [StopWordOptions](README.md#stopwordoptions)
Expand Down Expand Up @@ -71,7 +72,19 @@ A function that defines a circle for `.inCircle` searches.

#### Defined in

[lib/search/where-point.ts:9](https://github.com/redis/redis-om-node/blob/0843d26/lib/search/where-point.ts#L9)
[lib/search/where-point.ts:9](https://github.com/redis/redis-om-node/blob/9708a58/lib/search/where-point.ts#L9)

___

### DataStructure

Ƭ **DataStructure**: ``"HASH"`` \| ``"JSON"``

The type of data structure in Redis to map objects to.

#### Defined in

[lib/schema/options/data-structure.ts:2](https://github.com/redis/redis-om-node/blob/9708a58/lib/schema/options/data-structure.ts#L2)

___

Expand Down Expand Up @@ -101,20 +114,7 @@ A constructor that creates an [Entity](classes/Entity.md) of type TEntity.

#### Defined in

[lib/entity/entity.ts:18](https://github.com/redis/redis-om-node/blob/0843d26/lib/entity/entity.ts#L18)

___

### EntityCreationData

Ƭ **EntityCreationData**: `Record`<`string`, `number` \| `boolean` \| `string` \| `string`[] \| [`Point`](README.md#point) \| `Date` \| ``null``\>

Initialization data for [Entity](classes/Entity.md) creation when calling
[Repository.createEntity](classes/Repository.md#createentity) or [Repository.createAndSave](classes/Repository.md#createandsave).

#### Defined in

[lib/repository/repository.ts:15](https://github.com/redis/redis-om-node/blob/0843d26/lib/repository/repository.ts#L15)
[lib/entity/entity-constructor.ts:8](https://github.com/redis/redis-om-node/blob/9708a58/lib/entity/entity-constructor.ts#L8)

___

Expand All @@ -126,31 +126,31 @@ A JavaScript object containing the underlying data of an [Entity](classes/Entity

#### Defined in

[lib/entity/entity.ts:12](https://github.com/redis/redis-om-node/blob/0843d26/lib/entity/entity.ts#L12)
[lib/entity/entity-data.ts:6](https://github.com/redis/redis-om-node/blob/9708a58/lib/entity/entity-data.ts#L6)

___

### EntityValue

Ƭ **EntityValue**: `number` \| `boolean` \| `string` \| [`Point`](README.md#point) \| `Date` \| `string`[]
Ƭ **EntityValue**: `string` \| `number` \| `boolean` \| [`Point`](README.md#point) \| `Date` \| `any`[] \| ``null``

Valid values for properties of an [Entity](classes/Entity.md).
Valid types for properties on an [Entity](classes/Entity.md).

#### Defined in

[lib/entity/entity.ts:7](https://github.com/redis/redis-om-node/blob/0843d26/lib/entity/entity.ts#L7)
[lib/entity/entity-value.ts:6](https://github.com/redis/redis-om-node/blob/9708a58/lib/entity/entity-value.ts#L6)

___

### FieldDefinition

Ƭ **FieldDefinition**: [`StringField`](interfaces/StringField.md) \| [`TextField`](interfaces/TextField.md) \| [`NumberField`](interfaces/NumberField.md) \| [`BooleanField`](interfaces/BooleanField.md) \| [`PointField`](interfaces/PointField.md) \| [`DateField`](interfaces/DateField.md) \| [`StringArrayField`](interfaces/StringArrayField.md)
Ƭ **FieldDefinition**: [`StringFieldDefinition`](interfaces/StringFieldDefinition.md) \| [`TextFieldDefinition`](interfaces/TextFieldDefinition.md) \| [`NumberFieldDefinition`](interfaces/NumberFieldDefinition.md) \| [`BooleanFieldDefinition`](interfaces/BooleanFieldDefinition.md) \| [`PointFieldDefinition`](interfaces/PointFieldDefinition.md) \| [`DateFieldDefinition`](interfaces/DateFieldDefinition.md) \| [`StringArrayFieldDefinition`](interfaces/StringArrayFieldDefinition.md)

Contains instructions telling how to map a property on an [Entity](classes/Entity.md) to Redis.

#### Defined in

[lib/schema/definition/schema-definitions.ts:81](https://github.com/redis/redis-om-node/blob/0843d26/lib/schema/definition/schema-definitions.ts#L81)
[lib/schema/definition/field-definition.ts:10](https://github.com/redis/redis-om-node/blob/9708a58/lib/schema/definition/field-definition.ts#L10)

___

Expand All @@ -170,7 +170,7 @@ A function that generates random [Entity IDs](classes/Entity.md#entityid).

#### Defined in

[lib/schema/definition/schema-definitions.ts:89](https://github.com/redis/redis-om-node/blob/0843d26/lib/schema/definition/schema-definitions.ts#L89)
[lib/schema/options/id-strategy.ts:2](https://github.com/redis/redis-om-node/blob/9708a58/lib/schema/options/id-strategy.ts#L2)

___

Expand All @@ -189,7 +189,7 @@ Defines a point on the globe using longitude and latitude.

#### Defined in

[lib/schema/definition/schema-definitions.ts:2](https://github.com/redis/redis-om-node/blob/0843d26/lib/schema/definition/schema-definitions.ts#L2)
[lib/entity/point.ts:2](https://github.com/redis/redis-om-node/blob/9708a58/lib/entity/point.ts#L2)

___

Expand All @@ -201,7 +201,19 @@ Group of [FieldDefinition](README.md#fielddefinition)s that define the schema fo

#### Defined in

[lib/schema/definition/schema-definitions.ts:86](https://github.com/redis/redis-om-node/blob/0843d26/lib/schema/definition/schema-definitions.ts#L86)
[lib/schema/definition/schema-definition.ts:6](https://github.com/redis/redis-om-node/blob/9708a58/lib/schema/definition/schema-definition.ts#L6)

___

### SchemaFieldType

Ƭ **SchemaFieldType**: ``"string"`` \| ``"number"`` \| ``"boolean"`` \| ``"text"`` \| ``"date"`` \| ``"point"`` \| ``"array"``

Valid types a [FieldDefinition](README.md#fielddefinition).

#### Defined in

[lib/schema/definition/schema-field-type.ts:4](https://github.com/redis/redis-om-node/blob/9708a58/lib/schema/definition/schema-field-type.ts#L4)

___

Expand All @@ -215,7 +227,7 @@ Configuration options for a [Schema](classes/Schema.md).

| Name | Type | Description |
| :------ | :------ | :------ |
| `dataStructure?` | [`SearchDataStructure`](README.md#searchdatastructure) | The data structure used to store the [Entity](classes/Entity.md) in Redis. Can be set to either `JSON` or `HASH`. Defaults to JSON. |
| `dataStructure?` | [`DataStructure`](README.md#datastructure) | The data structure used to store the [Entity](classes/Entity.md) in Redis. Can be set to either `JSON` or `HASH`. Defaults to JSON. |
| `idStrategy?` | [`IdStrategy`](README.md#idstrategy) | A function that generates a random [Entity ID](classes/Entity.md#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`. |
Expand All @@ -225,7 +237,7 @@ Configuration options for a [Schema](classes/Schema.md).

#### Defined in

[lib/schema/schema-options.ts:7](https://github.com/redis/redis-om-node/blob/0843d26/lib/schema/schema-options.ts#L7)
[lib/schema/options/schema-options.ts:9](https://github.com/redis/redis-om-node/blob/9708a58/lib/schema/options/schema-options.ts#L9)

___

Expand All @@ -237,7 +249,7 @@ The type of data structure in Redis to map objects to.

#### Defined in

[lib/client.ts:21](https://github.com/redis/redis-om-node/blob/0843d26/lib/client.ts#L21)
[lib/client.ts:21](https://github.com/redis/redis-om-node/blob/9708a58/lib/client.ts#L21)

___

Expand All @@ -249,7 +261,7 @@ Valid values for how to use stop words for a given [Schema](classes/Schema.md).

#### Defined in

[lib/schema/definition/schema-definitions.ts:92](https://github.com/redis/redis-om-node/blob/0843d26/lib/schema/definition/schema-definitions.ts#L92)
[lib/schema/options/stop-word-options.ts:2](https://github.com/redis/redis-om-node/blob/9708a58/lib/schema/options/stop-word-options.ts#L2)

___

Expand Down Expand Up @@ -281,4 +293,4 @@ A function that takes a [Search](classes/Search.md) and returns a [Search](class

#### Defined in

[lib/search/search.ts:27](https://github.com/redis/redis-om-node/blob/0843d26/lib/search/search.ts#L27)
[lib/search/search.ts:27](https://github.com/redis/redis-om-node/blob/9708a58/lib/search/search.ts#L27)
Loading

0 comments on commit e5ab2ab

Please sign in to comment.