redis-om-node
redis-om-node copied to clipboard
Save JSON's array into JSON
Hi there, I am not really experienced with redis or schemas and stuff and this is what I wanted to use:
Schema:
{
ID: string,
warns: [
{ reason: "Something", id: "1" },
{ reason: "something else", id: "2" }
]
}
How can I do this? I am really confused. Thanks!
In the schema you would define the warns as an array (currently string[]
) and on the interface
(assuming you are using typescript) create a tuple.
interface YourInterface {
ID: string;
warns: [{ reason: string, id: string }];
}
In the schema you would define the warns as an array (currently
string[]
) and on theinterface
(assuming you are using typescript) create a tuple.interface YourInterface { ID: string; warns: [{ reason: string, id: string }]; }
Thanks, but does that mean I have to parse it as a JSON every time I want to get each and every warn? And also have to parse it as a string and push to the database?
In the schema you would define the warns as an array (currently
string[]
) and on theinterface
(assuming you are using typescript) create a tuple.interface YourInterface { ID: string; warns: [{ reason: string, id: string }]; }
Thanks, but does that mean I have to parse it as a JSON every time I want to get each and every warn? And also have to parse it as a string and push to the database?
In redis-om you should be able to just save the json, but if you have any issues regarding saving it directly as a json tell me because im actually not sure
Redis OM only supports an array of strings right now and doesn't support nested object structures. The latter is being worked on.