#Nesting Schema (referencing another schema)

36 messages · Page 1 of 1 (latest)

tough heron
#

Hi there. I’m just getting started with Redis OM. Could someone please show me how to simply reference another Schema?
I don’t see it in the documentation yet, and I’ve seen that the functionality is implemented according to some Closed issues in the GitHub, but I can’t find just one example of how to actually do it. Thank you 🙏

#

When I try to reference another Schema I just get:
InvalidSchema [Error]: The field 'person' is configured with a type of 'undefined'. Valid types include 'boolean', 'date', 'number', 'number[]', 'point', 'string', 'string[]', and 'text'.

#

I’m running the latest version of OM node (but not the beta, because it’s implemented in the base version?)

#

Nesting Schema / referencing another Schema

#

Nesting Schema referencing another schema

#

Nesting Schema (referencing another schema)

proud flare
#

There is no way to do this currently in redis-om, and i dont remember an issue like this being closed, tho i might be wrong...

tough heron
#

…back in 0.4.0, but I can’t figure out how to actually do it. I can’t find any examples/documentation on how to actually do it

proud flare
#

oh right... this was not implemented the way you might expect...

#

#redis-general message

tough heron
proud flare
#

this would be the redis-om way to do it: #redis-general message

tough heron
#

Thank you this helps a lot. As someone starting out, would you recommend I go down the path of the first option instead of the second? The first (Nekdis) looks like it allows the data to be more structured, but this is this first I’m hearing about “nekdis” and it looks like I’d also need a Nekdis db behind the scenes?

proud flare
#

nekdis is just a proposal for redis-om, it was intended to be merged with redis-om but... redis-om doesnt have a maintainer rn so the merger never went forward and redis-om has been inactive for a while...

#

i would just say to pick what you think its best for your use case

tough heron
#

Which one is more likely to be maintained into the future? Or is there another alternative? (I feel like I’m missing something lol)

proud flare
#

Well, i cant say for sure specially when it comes to redis-om since im not part of the team, as for nekdis there are some big changes to come in the future.
As far as alternatives go im not aware of any alternative for either of them for typescript/javascript

tough heron
#

I’m using node, so I’m just after a fast (in memory) way to access/store/persist data in a logical way (eg. JSON)

#

I was using mongodb but not fast enough

proud flare
#

Well, redis does that for you with ReJSON
Both redis-om and Nekdis just add an abstraction on top that allows you to model your data and work with it in a more safe way

tough heron
#

therefore, going to Redis from mongo feels less structured

proud flare
tough heron
#

Yeah. As I’m starting out, I’m slightly worried that if I go with Nekdis (which currently looks great) then my stored data may be inaccessible when things change without major refactoring?

#

But based on what you say about a layer of abstraction above, I probably don’t need to worry about that?

#

(because ultimately, it’s all stored via RedisJSON)

proud flare
proud flare
# tough heron But based on what you say about a layer of abstraction above, I probably don’t n...

Well yeah, your data will always be accessible what could happen because the packages are not in a 1.0 state its that apis change and you have to refactor your code a bit, but the data should never become inaccessible unless its some big thing like moving to an entire new way of parsing data types but usually when those things happen they are documented on the changelog so i would assume it would be alright

tough heron
#

Ok, so in your first example it references an Array as the children. Is it possible to do similar with another schema that’s just a single one (an object)?

#

I suppose using the “type: reference”?

tough heron
#

I’m experimenting with Didas and Redis-OM-node. In Redis-OM, do you happen to know if there’s value in specifying “sortable: true” in the schema when I’m doing a “.search” with a “.is.greaterThan(date)” on that parameter? (ie. is greaterThan “sorting” behind the scenes)?

proud flare
#

No, greaterThan is just normal number search

#

Its just [(x +inf]

#

sortable only applies to sortBy and related methods