incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Davis <paul.joseph.da...@gmail.com>
Subject Re: Problems with array with include_docs
Date Mon, 30 May 2011 16:22:53 GMT
include_docs won't work when the _id is nested in an array like that.
Your value *must* be an object that contains an _id member.

On Mon, May 30, 2011 at 10:35 AM, Ladislav Prskavec
<ladislav@prskavec.net> wrote:
> Hello,
> i have problem with my views. View 1 work's fine, geting parent document by _id, but
in View 2 by include_docs=true not get parent document requested by '_id': XXX.
>
> # View 1
>
> function(doc) {
> for (var idx in doc.studyList) {
>  if (doc.studyList[idx].focusId!="" && doc.studyList[idx].focusId!=null) {
> var pole = doc.studyList[idx].focusId.split(/[ -]+/);
> for (var i=0; i<pole.length;i++) {
> emit([pole[i], doc.parentId], {'_id': doc.parentId});
> }
>  }
> }
> }
>
>
> _design/fields/_view/focusIdtest?include_docs=true
>
> {"id":"7L000","key":["1002",0],"value":{"_id":0},"doc":null},
> {"id":"13430","key":["1002","13000"],"value":{"_id":"13000"},"doc":{"_id":"13000","_rev"
...
>
>
> # View 2
>
> function(doc) {
> for (var idx in doc.studyList) {
>  if (doc.studyList[idx].focusId!="" && doc.studyList[idx].focusId!=null) {
> var pole = doc.studyList[idx].focusId.split(/[ -]+/);
> for (var i=0; i<pole.length;i++) {
> emit([pole[i]], [doc.parentId, {'_id': doc.parentId}]);
> }
>  }
> }
> }
>
> _design/fields/_view/focusIdtest2?include_docs=true
>
> {"id":"13430","key":["1002"],"value":["13000",{"_id":"13000"}],"doc":{"_id":"13430" ...
>
>
> Can help how make work View2?
>
> I can use array in value but doesn't work in this example.
>
> Thanks all to help.
>
> Ladislav
>
>
>
>

Mime
View raw message