Question

I have objects like this in my mongodb db stored in a field type of hash:

"owner": {
     "user_id": 
  },
   "answers": {
     "items": {
       "0": {
         "owner": {
           "reputation": 
           "user_id": 
           "user_type": 
           "profile_image": 
           "display_name": 
           "link":
        },
         "is_accepted": 
         "score": 
         "last_activity_date": 
         "last_edit_date": 
         "creation_date": 
         "answer_id": 
         "question_id":
      } 
    },
     "has_more": false,
  },
   "is_answered": true,
   "view_count": 
   "answer_count":
   "score": 
}

I'm a bit confused on how to query answers.items.<any number>.score.gte => 1 with mongoid. I've tried a few different options but I can't seem to find something that works.

Was it helpful?

Solution

I was able to solve this by just skipping the number and just using using (:"answer.score".gte => 1)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top