Closed doprdele closed 6 years ago
No, such functionality does not currently exist in nohm.
min and max I wouldn't even know what that would mean in non-integer field indices.
limit and offset don't exist because non-integer indices are basically just sets where each id that has this index value is put in.
What are your use cases for this and what would you expect to happen for these things?
Maritz,
Basically I have N users, and each user can have any number of jobs. They launch jobs through a web interface. When these jobs are launched, they're placed into redis with nohm.
So, I would like to say
Grab N jobs running for this particular user
I imagine if I generate numeric IDs for all of them this would be possible, yes?
Best, Evan
In that case just create 2 models, one for users, one for jobs.
When a user creates a new job, user.link(job)
that user to that job.
Then whenever you want a users jobs call user.getAll('JobModel')
to get all job ids. See the relation docs and the relation tests for more information.
Feel free to re-open if anything is still unclear or doesn't work as you need it.
Hi Maritz,
Good idea -- I'll use that -- but, a user could have 200,000 jobs. Returning 200,000 jobs in a JSON document and loaded by a web browser may impact latency and overall user experience. So, how could I implement paging with this model as you can with numerical fields?
Best, Evan
If you really get to such numbers I would suggest doing the queries yourself with some redis lua script(s). I have no experience doing this though.
Also, when going against performance problems like that it's usually a good idea to do the simplest solution first, benchmark it and go from there. Maybe it's not even a problem.
Hi,
According to the documentation you can only .find() with a limit, offset, min and max for an integer field. Is it possible to do so with an indexed string field?
Thanks!