Filter data in couchbase View -


when write view in couchbase return whole doc return _sync":{} data, there way remove data response.

here view function:-

function map(doc, meta) {     if (doc.type == 'user' && doc.user_id) {         emit(doc.user_id, doc);     } } 

first off, shouldn't ever have emit whole doc. makes index bigger on disk, , it's redudant since can whole doc view row (the doc id included, , sdks transparently fetch usually).

in case though, may need second part of emit. select attributes interested in , emit them in array (like emit(doc.user_id, [doc.attributea, doc.attributeb])), "filtering out" _sync.

only problem if later on add attributec users, won't automatically included (so filters out attributes not explicitly listed in map function). make sense?


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -