redis-om-type 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG +168 -0
- package/LICENSE +22 -0
- package/README.md +1150 -0
- package/dist/index.d.ts +1398 -0
- package/dist/index.js +2047 -0
- package/docs/.nojekyll +1 -0
- package/docs/README.md +479 -0
- package/docs/classes/AbstractSearch.md +912 -0
- package/docs/classes/ArrayHashInput.md +198 -0
- package/docs/classes/Circle.md +375 -0
- package/docs/classes/Client.md +190 -0
- package/docs/classes/Field.md +254 -0
- package/docs/classes/FieldNotInSchema.md +198 -0
- package/docs/classes/InvalidHashInput.md +213 -0
- package/docs/classes/InvalidHashValue.md +228 -0
- package/docs/classes/InvalidInput.md +207 -0
- package/docs/classes/InvalidJsonInput.md +228 -0
- package/docs/classes/InvalidJsonValue.md +228 -0
- package/docs/classes/InvalidSchema.md +197 -0
- package/docs/classes/InvalidValue.md +203 -0
- package/docs/classes/NestedHashInput.md +198 -0
- package/docs/classes/NullJsonInput.md +228 -0
- package/docs/classes/NullJsonValue.md +228 -0
- package/docs/classes/PointOutOfRange.md +203 -0
- package/docs/classes/RawSearch.md +1063 -0
- package/docs/classes/RedisOmError.md +207 -0
- package/docs/classes/Repository.md +425 -0
- package/docs/classes/Schema.md +242 -0
- package/docs/classes/Search.md +1199 -0
- package/docs/classes/SearchError.md +201 -0
- package/docs/classes/SemanticSearchError.md +197 -0
- package/docs/classes/Where.md +43 -0
- package/docs/classes/WhereField.md +915 -0
- package/logo.svg +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
[redis-om](../README.md) / Schema
|
|
2
|
+
|
|
3
|
+
# Class: Schema
|
|
4
|
+
|
|
5
|
+
Defines a schema that determines how an [Entity](../README.md#entity) is mapped
|
|
6
|
+
to Redis data structures. Construct by passing in a schema name,
|
|
7
|
+
a [SchemaDefinition](../README.md#schemadefinition), and optionally [SchemaOptions](../README.md#schemaoptions):
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
const schema = new Schema('foo', {
|
|
11
|
+
aString: { type: 'string' },
|
|
12
|
+
aNumber: { type: 'number' },
|
|
13
|
+
aBoolean: { type: 'boolean' },
|
|
14
|
+
someText: { type: 'text' },
|
|
15
|
+
aPoint: { type: 'point' },
|
|
16
|
+
aDate: { type: 'date' },
|
|
17
|
+
someStrings: { type: 'string[]' }
|
|
18
|
+
}, {
|
|
19
|
+
dataStructure: 'HASH'
|
|
20
|
+
})
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
A Schema is primarily used by a [Repository](Repository.md) which requires a Schema in
|
|
24
|
+
its constructor.
|
|
25
|
+
|
|
26
|
+
## Table of contents
|
|
27
|
+
|
|
28
|
+
### Constructors
|
|
29
|
+
|
|
30
|
+
- [constructor](Schema.md#constructor)
|
|
31
|
+
|
|
32
|
+
### Accessors
|
|
33
|
+
|
|
34
|
+
- [dataStructure](Schema.md#datastructure)
|
|
35
|
+
- [fields](Schema.md#fields)
|
|
36
|
+
- [indexHash](Schema.md#indexhash)
|
|
37
|
+
- [indexHashName](Schema.md#indexhashname)
|
|
38
|
+
- [indexName](Schema.md#indexname)
|
|
39
|
+
- [schemaName](Schema.md#schemaname)
|
|
40
|
+
- [stopWords](Schema.md#stopwords)
|
|
41
|
+
- [useStopWords](Schema.md#usestopwords)
|
|
42
|
+
|
|
43
|
+
### Methods
|
|
44
|
+
|
|
45
|
+
- [fieldByName](Schema.md#fieldbyname)
|
|
46
|
+
- [generateId](Schema.md#generateid)
|
|
47
|
+
|
|
48
|
+
## Constructors
|
|
49
|
+
|
|
50
|
+
### constructor
|
|
51
|
+
|
|
52
|
+
• **new Schema**(`schemaName`, `schemaDef`, `options?`)
|
|
53
|
+
|
|
54
|
+
Constructs a Schema.
|
|
55
|
+
|
|
56
|
+
#### Parameters
|
|
57
|
+
|
|
58
|
+
| Name | Type | Description |
|
|
59
|
+
| :------ | :------ | :------ |
|
|
60
|
+
| `schemaName` | `string` | The name of the schema. Prefixes the ID when creating Redis keys. |
|
|
61
|
+
| `schemaDef` | [`SchemaDefinition`](../README.md#schemadefinition) | Defines all of the fields for the Schema and how they are mapped to Redis. |
|
|
62
|
+
| `options?` | [`SchemaOptions`](../README.md#schemaoptions) | Additional options for this Schema. |
|
|
63
|
+
|
|
64
|
+
#### Defined in
|
|
65
|
+
|
|
66
|
+
[lib/schema/schema.ts:49](https://github.com/redis/redis-om-node/blob/d8438f7/lib/schema/schema.ts#L49)
|
|
67
|
+
|
|
68
|
+
## Accessors
|
|
69
|
+
|
|
70
|
+
### dataStructure
|
|
71
|
+
|
|
72
|
+
• `get` **dataStructure**(): [`DataStructure`](../README.md#datastructure)
|
|
73
|
+
|
|
74
|
+
The configured data structure, a string with the value of either `HASH` or `JSON`,
|
|
75
|
+
that this Schema uses to store [Entities](../README.md#entity) in Redis.
|
|
76
|
+
|
|
77
|
+
#### Returns
|
|
78
|
+
|
|
79
|
+
[`DataStructure`](../README.md#datastructure)
|
|
80
|
+
|
|
81
|
+
#### Defined in
|
|
82
|
+
|
|
83
|
+
[lib/schema/schema.ts:92](https://github.com/redis/redis-om-node/blob/d8438f7/lib/schema/schema.ts#L92)
|
|
84
|
+
|
|
85
|
+
___
|
|
86
|
+
|
|
87
|
+
### fields
|
|
88
|
+
|
|
89
|
+
• `get` **fields**(): [`Field`](Field.md)[]
|
|
90
|
+
|
|
91
|
+
The [Fields](Field.md) defined by this Schema.
|
|
92
|
+
|
|
93
|
+
#### Returns
|
|
94
|
+
|
|
95
|
+
[`Field`](Field.md)[]
|
|
96
|
+
|
|
97
|
+
#### Defined in
|
|
98
|
+
|
|
99
|
+
[lib/schema/schema.ts:68](https://github.com/redis/redis-om-node/blob/d8438f7/lib/schema/schema.ts#L68)
|
|
100
|
+
|
|
101
|
+
___
|
|
102
|
+
|
|
103
|
+
### indexHash
|
|
104
|
+
|
|
105
|
+
• `get` **indexHash**(): `string`
|
|
106
|
+
|
|
107
|
+
A hash for this Schema that is used to determine if the Schema has been
|
|
108
|
+
changed when calling [createIndex](Repository.md#createindex).
|
|
109
|
+
|
|
110
|
+
#### Returns
|
|
111
|
+
|
|
112
|
+
`string`
|
|
113
|
+
|
|
114
|
+
#### Defined in
|
|
115
|
+
|
|
116
|
+
[lib/schema/schema.ts:120](https://github.com/redis/redis-om-node/blob/d8438f7/lib/schema/schema.ts#L120)
|
|
117
|
+
|
|
118
|
+
___
|
|
119
|
+
|
|
120
|
+
### indexHashName
|
|
121
|
+
|
|
122
|
+
• `get` **indexHashName**(): `string`
|
|
123
|
+
|
|
124
|
+
The configured name for the RediSearch index hash for this Schema.
|
|
125
|
+
|
|
126
|
+
#### Returns
|
|
127
|
+
|
|
128
|
+
`string`
|
|
129
|
+
|
|
130
|
+
#### Defined in
|
|
131
|
+
|
|
132
|
+
[lib/schema/schema.ts:86](https://github.com/redis/redis-om-node/blob/d8438f7/lib/schema/schema.ts#L86)
|
|
133
|
+
|
|
134
|
+
___
|
|
135
|
+
|
|
136
|
+
### indexName
|
|
137
|
+
|
|
138
|
+
• `get` **indexName**(): `string`
|
|
139
|
+
|
|
140
|
+
The configured name for the RediSearch index for this Schema.
|
|
141
|
+
|
|
142
|
+
#### Returns
|
|
143
|
+
|
|
144
|
+
`string`
|
|
145
|
+
|
|
146
|
+
#### Defined in
|
|
147
|
+
|
|
148
|
+
[lib/schema/schema.ts:83](https://github.com/redis/redis-om-node/blob/d8438f7/lib/schema/schema.ts#L83)
|
|
149
|
+
|
|
150
|
+
___
|
|
151
|
+
|
|
152
|
+
### schemaName
|
|
153
|
+
|
|
154
|
+
• `get` **schemaName**(): `string`
|
|
155
|
+
|
|
156
|
+
The name of the schema. Prefixes the ID when creating Redis keys. Combined
|
|
157
|
+
with the results of idStrategy to generate a key. If name is `foo` and
|
|
158
|
+
idStrategy returns `12345` then the generated key would be `foo:12345`.
|
|
159
|
+
|
|
160
|
+
#### Returns
|
|
161
|
+
|
|
162
|
+
`string`
|
|
163
|
+
|
|
164
|
+
#### Defined in
|
|
165
|
+
|
|
166
|
+
[lib/schema/schema.ts:63](https://github.com/redis/redis-om-node/blob/d8438f7/lib/schema/schema.ts#L63)
|
|
167
|
+
|
|
168
|
+
___
|
|
169
|
+
|
|
170
|
+
### stopWords
|
|
171
|
+
|
|
172
|
+
• `get` **stopWords**(): `string`[]
|
|
173
|
+
|
|
174
|
+
The configured stop words. Ignored if [useStopWords](Schema.md#usestopwords) is anything other
|
|
175
|
+
than `CUSTOM`.
|
|
176
|
+
|
|
177
|
+
#### Returns
|
|
178
|
+
|
|
179
|
+
`string`[]
|
|
180
|
+
|
|
181
|
+
#### Defined in
|
|
182
|
+
|
|
183
|
+
[lib/schema/schema.ts:104](https://github.com/redis/redis-om-node/blob/d8438f7/lib/schema/schema.ts#L104)
|
|
184
|
+
|
|
185
|
+
___
|
|
186
|
+
|
|
187
|
+
### useStopWords
|
|
188
|
+
|
|
189
|
+
• `get` **useStopWords**(): [`StopWordOptions`](../README.md#stopwordoptions)
|
|
190
|
+
|
|
191
|
+
The configured usage of stop words, a string with the value of either `OFF`, `DEFAULT`,
|
|
192
|
+
or `CUSTOM`. See [SchemaOptions](../README.md#schemaoptions) for more details.
|
|
193
|
+
|
|
194
|
+
#### Returns
|
|
195
|
+
|
|
196
|
+
[`StopWordOptions`](../README.md#stopwordoptions)
|
|
197
|
+
|
|
198
|
+
#### Defined in
|
|
199
|
+
|
|
200
|
+
[lib/schema/schema.ts:98](https://github.com/redis/redis-om-node/blob/d8438f7/lib/schema/schema.ts#L98)
|
|
201
|
+
|
|
202
|
+
## Methods
|
|
203
|
+
|
|
204
|
+
### fieldByName
|
|
205
|
+
|
|
206
|
+
▸ **fieldByName**(`name`): ``null`` \| [`Field`](Field.md)
|
|
207
|
+
|
|
208
|
+
Gets a single [Field](Field.md) defined by this Schema.
|
|
209
|
+
|
|
210
|
+
#### Parameters
|
|
211
|
+
|
|
212
|
+
| Name | Type | Description |
|
|
213
|
+
| :------ | :------ | :------ |
|
|
214
|
+
| `name` | `string` | The name of the [Field](Field.md) in this Schema. |
|
|
215
|
+
|
|
216
|
+
#### Returns
|
|
217
|
+
|
|
218
|
+
``null`` \| [`Field`](Field.md)
|
|
219
|
+
|
|
220
|
+
The [Field](Field.md), or null of not found.
|
|
221
|
+
|
|
222
|
+
#### Defined in
|
|
223
|
+
|
|
224
|
+
[lib/schema/schema.ts:78](https://github.com/redis/redis-om-node/blob/d8438f7/lib/schema/schema.ts#L78)
|
|
225
|
+
|
|
226
|
+
___
|
|
227
|
+
|
|
228
|
+
### generateId
|
|
229
|
+
|
|
230
|
+
▸ **generateId**(): `Promise`<`string`\>
|
|
231
|
+
|
|
232
|
+
Generates a unique string using the configured [IdStrategy](../README.md#idstrategy).
|
|
233
|
+
|
|
234
|
+
#### Returns
|
|
235
|
+
|
|
236
|
+
`Promise`<`string`\>
|
|
237
|
+
|
|
238
|
+
The generated id.
|
|
239
|
+
|
|
240
|
+
#### Defined in
|
|
241
|
+
|
|
242
|
+
[lib/schema/schema.ts:111](https://github.com/redis/redis-om-node/blob/d8438f7/lib/schema/schema.ts#L111)
|