1 Reply Latest reply on Apr 17, 2013 3:42 AM by Kutir Mobility

    Advanced queries in rhom

      I was going through the docs and came across this thing


      can anyone tell me what assumptions are we makin and what are we trying to do with the queries mentioned in the docs...?





        • Re: Advanced queries in rhom
          Kutir Mobility

          Hi Divyansh Madan,


          For Property bag table you wont be able to write raw sql_query like Account.find_by_sql("SELECT * FROM Account")           .

          Using Advanced queries, which rhom can optimize the query for the property bag table.

          A normal query would look like this:

          @employees = Employee.find(:all, :conditions =>{'gender' => @params['gender'],'company_id'=> @params['company_id']})

          If you want to get only certain entities for example in this case retrive only employee gender and employee company id along

          with using "like" query , we would go for advanced queries




          @employees = Employee.find(:all, :conditions =>{'gender' => 'female','company_id'=> '123'})

          will retrive all the attributes of the Employee table

          [{:source_id=>14, :object=>"13092306_1", :description=>"Description", :name=>"xxx", :department=>"employee department", :gender=>"female",:company_id="123"}]

          Advanced query :

          @employees = Employee.find(:all, :conditions =>{{:name =>'gender' ,:op =>"like"} => 'female',{:name =>'company_id', :op => 'like'}=>'123',:op => 'AND')

          will retrive only gender like "female" and company_id like "123"

          [{:source_id=>14, :object=>"", :gender=>"female", :company_id=>"123"}]




          Kutir Mobility