couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard Llewellyn <>
Subject a newbie question about querying an exact array field
Date Wed, 21 Jul 2010 16:47:37 GMT

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:

 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

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

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?


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message