Does this look a bit like it:
module Sequel
module Plugins
module Odata
module ClassMethods
def odata_query(params)
self.dataset.odata_query(params)
end
end
module DatasetMethods
def odata_query(params)
result = self
top = params[:$top]
skip = params[:$skip]
orderby = params[:$orderby]
if orderby
if orderby.include?('desc')
result = result.order(Sequel.desc(orderby.split[0]))
else
result = result.order(orderby.split[0])
end
end
if skip
result = result.offset(skip)
end
if top
result = result.limit(top)
end
result
end
end
end
end
end
*Met vriendelijke groet / Kind regards, Marcel van PinxterenSr. Programmeur*
*Bottom Line Software B.V. [email protected] <[email protected]>*
On 24 February 2014 17:04, Jeremy Evans <[email protected]> wrote:
> On Monday, February 24, 2014 4:07:00 AM UTC-8, Marcel van Pinxteren wrote:
>>
>> We use Kendo Grid and Kendo DataSource in our views.
>> The standard way for Kendo to pass server side filtering and sorting
>> parameters to the server is in oData format.
>> An example of the parameters that the Rails controller gets:
>> {"$inlinecount"=>"allpages", "$top"=>"20", "$orderby"=>"ResourceName
>> desc", "$filter"=>"startswith(ResourceName,'T')"}
>>
>> Would this be a good candidate for a Sequel Model plugin? These
>> parameters should all be easily translatable to "order", "where", "skip"
>> and "limit" clauses.
>> Any suggestions to get started?
>>
>
> You could do it with a Sequel::Model plugin, but it may be better to just
> add a method to translate the values in the controller (taking that
> parameter hash and a base dataset, and returning a modified dataset).
> Whichever way you choose, you need to be very careful in handling the
> data, validating that ResourceName is a valid column, etc..
>
> Thanks,
> Jeremy
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "sequel-talk" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/sequel-talk/zSTubfdfclY/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sequel-talk.
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/groups/opt_out.