I'd say by hand writing the mongodb specific query, but I didn't follow 
closely the mongodb adapter implementation to say it for sure. AFAIK, using 
DAL you can only order,filter,etc etc by a field specified in your models. 
What instead you're trying to do is to filter/order by a value that is 
stored WITHIN the field (in your case, a json object).

On Monday, July 1, 2013 8:57:25 PM UTC+2, Giovanni Barillari wrote:
>
> Hi all,
> I've encountered a problem developing a web app with web2py, and would 
> like some suggestions on how to handle it.
>
> I'm using web2py (one of the latest trunk versions) with MongoDB, and I 
> have a table with a json field:
>
> Field("myfield", "json")
>
> which would store a dict() from my app with a variable number of keys, so 
> I don't know in advance how many keys are stored in the dict or what keys 
> the dict contains, so as an example I can have:
>
> - row n with myfield = {"a"=int, "b"=int}
>
> - row n+1 with myfield = {"c"=int}
>
> What I would like to do is to select a limited number of rows from my 
> table querying for a specific key (simplifying: something like 
> db(db.mytable.myfield.key=="something").select()), ordering them by the 
> values of that keys (that are always integers), so the result of the select 
> should be:
>
> - row n: myfield.a = 0
>
> - row n+1: myfield.a = 1
>
> How would you do that?
>
> Thanks,
>
> /Giovanni
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to