0

class name is Usersdata

In mongo

{id:100,createdby:900,.......}
{id:200,createdby:900,.......}
{id:300,createdby:900,.......}
{id:400,createdby:800,.......}
{id:500,createdby:800,.......}

I want to fetch all records having createdby=900..I tried this

Userdata.where(createdby: 900)

But not working

4

1 回答 1

1

Model.where returns a Criteria. You have to iterate over that to get all the results, the simplest being Userdata.where(createdby:900).to_a to get an array of the results.

于 2013-05-20T03:35:46.247 回答