Skip to content

Latest commit

 

History

History
223 lines (129 loc) · 5.07 KB

Schema.md

File metadata and controls

223 lines (129 loc) · 5.07 KB

redis-om / Schema

Class: Schema<TEntity>

Defines a schema that determines how an Entity is mapped to Redis data structures. Construct by passing in an EntityConstructor, a SchemaDefinition, and optionally SchemaOptions:

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 which requires a Schema in its constructor.

Type parameters

Name Type Description
TEntity extends Entity The Entity this Schema defines.

Table of contents

Constructors

Accessors

Methods

Constructors

constructor

new Schema<TEntity>(ctor, schemaDef, options?)

Type parameters

Name Type Description
TEntity extends Entity<TEntity> The Entity this Schema defines.

Parameters

Name Type Description
ctor EntityConstructor<TEntity> A constructor that creates an Entity of type TEntity.
schemaDef SchemaDefinition Defines all of the fields for the Schema and how they are mapped to Redis.
options? SchemaOptions Additional options for this Schema.

Defined in

lib/schema/schema.ts:57

Accessors

dataStructure

get dataStructure(): DataStructure

The configured data structure, a string with the value of either HASH or JSON, that this Schema uses to store Entities in Redis.

Returns

DataStructure

Defined in

lib/schema/schema.ts:79


indexHash

get indexHash(): string

The hash value of this index. Stored in Redis under Schema.indexHashName.

Returns

string

Defined in

lib/schema/schema.ts:100


indexHashName

get indexHashName(): string

The configured name for the RediSearch index hash for this Schema.

Returns

string

Defined in

lib/schema/schema.ts:73


indexName

get indexName(): string

The configured name for the RediSearch index for this Schema.

Returns

string

Defined in

lib/schema/schema.ts:70


indexedDefault

get indexedDefault(): boolean

The configured indexed default setting for fields

Returns

boolean

Defined in

lib/schema/schema.ts:97


prefix

get prefix(): string

The configured keyspace prefix in Redis for this Schema.

Returns

string

Defined in

lib/schema/schema.ts:67


stopWords

get stopWords(): string[]

The configured stop words. Ignored if Schema.useStopWords is anything other than CUSTOM.

Returns

string[]

Defined in

lib/schema/schema.ts:92


useStopWords

get useStopWords(): StopWordOptions

The configured usage of stop words, a string with the value of either OFF, DEFAULT, or CUSTOM. See {@link SchemaOptions.useStopWords} and {@link SchemaOptions.stopWords} for more details.

Returns

StopWordOptions

Defined in

lib/schema/schema.ts:86

Methods

generateId

generateId(): string

Generates a unique string using the configured IdStrategy.

Returns

string

Defined in

lib/schema/schema.ts:126