[Dojo-interest] how to use OR operator in fetching data from store

Jared Jurkiewicz jared.jurkiewicz at gmail.com
Thu Aug 28 15:24:50 UTC 2008


dojox.data.AndOrReadStore is part of dojo 1.2.



On Thu, Aug 28, 2008 at 1:23 AM, lukess <mail2lokesh at gmail.com> wrote:
>
> Hi all,
>
>  Thanks everyone for helping me out, but i have found the solution and here
> it comes:
>
> var tempnet =  3 +  " || val: "  + 4 +  " || val: " +5;
> var query = "{ complexQuery: (val: "+tempnet +")" + "AND "  +"(folder: \"" +
> temparray[i-1].id[0] +"\") }";
>
> where temparray is array and i am taking [i-1].id[0]th value.
>
> but you have to download one external file "AndOrReadStore.js" and put it
> under dojox.data folder. and also need to replace the store with
> AndOrReadStore
>
> i mean in my case i was using "FileReadStore" and now i am using
> "AndOrReadStore"
>
> AndOrReadStore.js file can be downloaded from
>
> http://trac.dojotoolkit.org/attachment/ticket/5873/tAndOrReadStore.js
> http://trac.dojotoolkit.org/attachment/ticket/5873/tAndOrReadStore.js
>
> Anthony Fryer wrote:
>>
>>
>>
>> It depends on the store you are using and where the source of your data
>> is.  I needed OR functionality a while ago and the source of my data was a
>> database, so  I ended up implementing my own store that uses SQL syntax in
>> the query attribute of the fetch method so I can pass that straight
>> through to the backend database.
>>
>> In some enviornments it is a bit of a security risk (passing sql queries
>> directly)  but for me the functionality is worth it and the app is used in
>> a secure environment anyway.  So depending on where you get your data from
>> this might be an option for you.
>>
>>> Date: Wed, 27 Aug 2008 20:53:24 -0700
>>> From: mail2lokesh at gmail.com
>>> To: dojo-interest at dojotoolkit.org
>>> Subject: Re: [Dojo-interest] how to use OR operator in fetching data from
>>> store
>>>
>>>
>>> Hi VSP,
>>>
>>>   i have already tried that trick, but that didn't work. I am badluy
>>> stuck
>>> into this problem.....
>>>
>>> V S P wrote:
>>> >
>>> > Even though I did not use reg expression in on fetch (I just use "*" ),
>>> > I think your regular expression that you pass to the query is not
>>> > correct
>>> > your tempvnet ends up containing
>>> >
>>> > val=3 | val=4 |val=5
>>> >
>>> >
>>> >
>>> > What you want is
>>> > 3|4|5
>>> >
>>> > you do not need the 'val' to be part of regular expression because it
>>> is
>>> > alredy supposed
>>> > to be a field name
>>> >
>>> > So say your data store has a field called
>>> > 'val'
>>> > (or it can be called 'id'  -- but you have to name it explicitly)
>>> >
>>> > and you want to fetch data based on the value in that field
>>> >
>>> > var tempnet = 3 +  "|"  + 4 +  "|" +5;
>>> >
>>> >    yourStore.fetch({
>>> >                    query:{val:tempnet},
>>> >                    scope:this,
>>> >                    onItem: function (itm)
>>> >                    {
>>> >                            console.debug("got item",itm);
>>> >                         }
>>> >                        });
>>> >
>>> > Note I typically set scope attribute to 'this' -- so that the scope of
>>> > the
>>> > onItem function is the same as the scope where it is being called
>>> > from...
>>> > But it is not needed in many cases.
>>> >
>>> >
>>> > and finally -- if the regular expression in tempnet is not
>>> > enough to do the filtering you want, you can just
>>> > var tempnent="*"
>>> >
>>> > and then onItem will get called for every element
>>> > and in there you can decide to ignore some items programmatically.
>>> >
>>> > I picked up a lot of info on the datastore stuff from the dojo
>>> > definitive
>>> > guide book -- saved me quite a few hours.
>>> >
>>> > VSP
>>> >
>>> >
>>> > On Wed, 27 Aug 2008 16:38:10 -0700 (PDT), "lukess"
>>> > <mail2lokesh at gmail.com> said:
>>> >>
>>> >> Hi,
>>> >>
>>> >>   I want to fetch values from a datastore, depending upon some
>>> opertaion.
>>> >> suppose i want to fetch all items where id ==1, id==2, id ==3; but i
>>> am
>>> >> not
>>> >> able to do that, and getting errors.
>>> >>
>>> >> my code is something like:
>>> >>
>>> >> var tempnet = "val=" +  3 +  " | val="  + 4 +  " |val=" +5;
>>> >> var query = {
>>> >>
>>> >>                     val: tempvnet;
>>> >>   };
>>> >>
>>> >> Please let me know because i am stuck at this point.
>>> >>
>>> >> Regards,
>>> >> Lukes
>>> >>
>>> >>
>>> >> --
>>> >> View this message in context:
>>> >>
>>> http://www.nabble.com/how-to-use-OR-operator-in-fetching-data-from-store-tp19191786p19191786.html
>>> >> Sent from the Dojo mailing list archive at Nabble.com.
>>> >>
>>> >> _______________________________________________
>>> >> FAQ: http://dojotoolkit.org/support/faq
>>> >> Book: http://dojotoolkit.org/docs/book
>>> >> Forums: http://dojotoolkit.org/forum
>>> >> Dojo-interest at dojotoolkit.org
>>> >> http://turtle.dojotoolkit.org/mailman/listinfo/dojo-interest
>>> > --
>>> >   V S P
>>> >   toreason at fastmail.fm
>>> >
>>> > --
>>> > http://www.fastmail.fm - A no graphics, no pop-ups email service
>>> >
>>> > _______________________________________________
>>> > FAQ: http://dojotoolkit.org/support/faq
>>> > Book: http://dojotoolkit.org/docs/book
>>> > Forums: http://dojotoolkit.org/forum
>>> > Dojo-interest at dojotoolkit.org
>>> > http://turtle.dojotoolkit.org/mailman/listinfo/dojo-interest
>>> >
>>> >
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/how-to-use-OR-operator-in-fetching-data-from-store-tp19191786p19193794.html
>>> Sent from the Dojo mailing list archive at Nabble.com.
>>>
>>> _______________________________________________
>>> FAQ: http://dojotoolkit.org/support/faq
>>> Book: http://dojotoolkit.org/docs/book
>>> Forums: http://dojotoolkit.org/forum
>>> Dojo-interest at dojotoolkit.org
>>> http://turtle.dojotoolkit.org/mailman/listinfo/dojo-interest
>>
>> _________________________________________________________________
>> It's simple! Sell your car for just $40 at CarPoint.com.au
>> http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fsecure%2Dau%2Eimrworldwide%2Ecom%2Fcgi%2Dbin%2Fa%2Fci%5F450304%2Fet%5F2%2Fcg%5F801459%2Fpi%5F1004813%2Fai%5F859641&_t=762955845&_r=tig_OCT07&_m=EXT
>> _______________________________________________
>> FAQ: http://dojotoolkit.org/support/faq
>> Book: http://dojotoolkit.org/docs/book
>> Forums: http://dojotoolkit.org/forum
>> Dojo-interest at dojotoolkit.org
>> http://turtle.dojotoolkit.org/mailman/listinfo/dojo-interest
>>
>>
>
> --
> View this message in context: http://www.nabble.com/how-to-use-OR-operator-in-fetching-data-from-store-tp19191786p19194389.html
> Sent from the Dojo mailing list archive at Nabble.com.
>
> _______________________________________________
> FAQ: http://dojotoolkit.org/support/faq
> Book: http://dojotoolkit.org/docs/book
> Forums: http://dojotoolkit.org/forum
> Dojo-interest at dojotoolkit.org
> http://turtle.dojotoolkit.org/mailman/listinfo/dojo-interest
>


More information about the Dojo-interest mailing list