Mongodb topic in rails

Hi

I use mongoid for rails application
and I try to do
@users = User.where(“first_name = ? OR last_name = ? OR type = ?”,
firstname, lastname, usertype)

but I am getting error
but when i put:
@users = User.where(:first_name => firstname, :last_name => lastname,
:type => usertype).all

the program run successfully
but i need OR to execute in mongodb
Also I need sql LIKE to execute in mongodb

I have learned the raw code of mongodb
but I need a help for Rails query

Could anyone help me ?
Thanks in Advance

Kausik

On 06 Dec 2011, at 17:14, Kausik B. wrote:

the program run successfully
but i need OR to execute in mongodb
Also I need sql LIKE to execute in mongodb

I have learned the raw code of mongodb
but I need a help for Rails query

Reading the documentation usually helps:

http://mongoid.org/docs/querying/criteria.html

Especially the “Model.any_of | Criteria#any_of” section seems to cover
your case.

Best regards

Peter De Berdt

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs