bjornharvold
Jul 15th, 2011, 11:56 AM
Let's say I want to retrieve a list of users from mongo, but I want to make the query faster by only returning the user data I will be working with.
E.g. autoCompleteUsername(username)
Result:
List<User>
Where only user.id and user.username are populated.
How would I do this?
In mongo it would look something like this:
db.testdb.user.find({"username" : /^johnsmi*/i}, {username:1}).skip(0).limit(30)
Cheers
bjorn
E.g. autoCompleteUsername(username)
Result:
List<User>
Where only user.id and user.username are populated.
How would I do this?
In mongo it would look something like this:
db.testdb.user.find({"username" : /^johnsmi*/i}, {username:1}).skip(0).limit(30)
Cheers
bjorn