Collection: years
Entry 1
{
_id: ObjectId("4f2fd2ee4516ed6ceebbe17c"),
shows: [
{
day: 1,
hasVideos: false,
month: 1,
showid: 1252187000,
venue: "Someplace"
},
{
day: 2,
hasVideos: false,
month: 2,
showid: 1252188010,
venue: "Philly"
}
],
year: 1988
}
Entry 2
{
_id: ObjectId("4f2fd2ee4516ed6ceebbe17c"),
shows: [
{
day: 19,
hasVideos: false,
month: 1,
showid: 1252187999,
venue: "Hunt's"
},
{
day: 21,
hasVideos: false,
month: 1,
showid: 1252188030,
venue: "Hunt's"
}
],
year: 1987
}
Now, I created a set called years in my redis store. This is populated with strings in the form of year:1988. I created a hash called year:1988. But this is wrong. I want to nest an array of these show hashes.
How can nest a hash two sets deep? Should I just continue the pattern and create a set in the form of 1988:01:01 and 1988:02:02 to store the first entry?
Thanks
If you only want to be able to query by date (or year) you should use a Sorted Set as lookup.
Sorted Sets on redis.io
What you want to do is use the show’s Id or the serialized show as the member and the date the show aired, or took place as the score.
Note that if you only store the shows Id you need to perform another lookup to get the shows’ details.
Now you can perform range queries which seems to be what you want:
ZRANGEBYSCORE
ZREVRANGEBYSCORE