Javascript doesn't allow you to compare arrays. You'll either have to json encode or hash the array and then compare the hashes.
On Wed, Jul 21, 2010 at 9:47 AM, Richard Llewellyn <[email protected]>wrote: > Hello, > > If I have a document with eg doc.my_array = [1,2,3,4,5] > > how do I query on the my_array field? > > I thought I could write a simple view: > > function(doc){ > if (doc.my_array == [1,2,3,4,5]) > { emit(null, doc) > }} > > but seems I must be missing something very basic, though I have mucho > googled, as this returns nothing in Futon. Or is this my ignorance of > javascript? > > I see that if I have a doc with a collection field eg: doc.my_collection = > {0:1, 1:2, 2:3, 3:4,4:5}, > I can retrieve it by converting the collection to a string > > function(doc){ > if (doc.my_collection) == "{0:1, 1:2, 2:3, 3:4,4:5}") > .... > as long as I am careful to format the string exactly right. So I could > store lists as collections with explicit indexes and retrieve them that > way. > Is this standard practice? > > > Thanks, > Rich > -- Jason Benesch We just launched www.TomatoUniversity.com - Join for free! Technology Training for the Real Estate Industry. Real Estate Tomato Co-owner www.realestatetomato.com (619) 770-1950 [email protected] ListingPress Owner, Founder www.listingpress.com (619) 955-7465 [email protected]
