couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard Llewellyn <llew...@gmail.com>
Subject a newbie question about querying an exact array field
Date Wed, 21 Jul 2010 16:47:37 GMT
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

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