Closed vicodinl closed 1 year ago
This should work:
const personSchema = new Schema('person', {
name: { type: 'string' },
age: { type: 'number' },
children: { type: 'string[]', path: '$.children[*].name' },
children: { type: 'number[]', path: '$.children[*].age' },
})
You don't have to define them if you won't be performing indexing or searching on them.
Not quite correct @aflorj but you've got the right idea.
const personSchema = new Schema('person', {
name: { type: 'string' },
age: { type: 'number' },
children_names: { type: 'string[]', path: '$.children[*].name' },
children_ages: { type: 'number[]', path: '$.children[*].age' },
})
And thanks for helping out!
Suppose there exists an object like this:
const person = { name: 'alice', age: 28, children: [ { name: 'bob', age: 4, }, { name: 'charlie', age: 5, } ], }
how to define the schema?By the way, utilizing entities within redis-om-spring is not only straightforward but also exudes simplicity and elegance. the requirement of defining a schema in Node.js can be quite challenging, particularly for intricate objects. is it necessory?