Skip to content

Latest commit

 

History

History
169 lines (99 loc) · 4.04 KB

Schema.md

File metadata and controls

169 lines (99 loc) · 4.04 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 SchemaOptions:

let schema = new Schema(Foo, {
  aString: { type: 'string' },
  aNumber: { type: 'number' },
  aBoolean: { type: 'boolean' },
  anArray: { type: 'array' }
}, {
  dataStructure: 'JSON'
});

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:53

Accessors

dataStructure

get dataStructure(): SearchDataStructure

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

Returns

SearchDataStructure

Defined in

lib/schema/schema.ts:72


indexName

get indexName(): string

The configured name for the RediSearch index for this Schema.

Returns

string

Defined in

lib/schema/schema.ts:66


prefix

get prefix(): string

The configured keyspace prefix in Redis for this Schema.

Returns

string

Defined in

lib/schema/schema.ts:63


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:85


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:79

Methods

generateId

generateId(): string

Generates a unique string using the configured IdStrategy.

Returns

string

Defined in

lib/schema/schema.ts:94