redis-om / Schema
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.
| Name | Type | Description |
|---|---|---|
TEntity |
extends Entity |
The Entity this Schema defines. |
• new Schema<TEntity>(ctor, schemaDef, options?)
| Name | Type | Description |
|---|---|---|
TEntity |
extends Entity<TEntity> |
The Entity this Schema defines. |
| 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. |
• 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.
• get indexHash(): string
The hash value of this index. Stored in Redis under Schema.indexHashName.
string
• get indexHashName(): string
The configured name for the RediSearch index hash for this Schema.
string
• get indexName(): string
The configured name for the RediSearch index for this Schema.
string
• get prefix(): string
The configured keyspace prefix in Redis for this Schema.
string
• get stopWords(): string[]
The configured stop words. Ignored if Schema.useStopWords is anything other
than CUSTOM.
string[]
• 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.
▸ generateId(): string
Generates a unique string using the configured IdStrategy.
string