couchDB: view that returns NOT NULL values, doesn't return NULL values -



couchDB: view that returns NOT NULL values, doesn't return NULL values -

i have couchdb database 2 types of documents. document has x items, document b has -y items.

every product has id, single document a, , many document b's associated it. (think of inventory. document has how many items @ start. document b represents sale/breakage etc).

i need produce view returns id's of products positive sum of items.

i have written map cut down so:

map:

function(doc) { if (doc.type === "delivery") { emit(doc.productid, doc.items ); } if (doc.type === "sale") { emit(doc.productid, -(doc.items)); } }

reduce:

function(keys, values) { var total = sum(values); if (total > 0) { homecoming total } }

when queried, returns whole lot of null values products don't have in stock. returns positive numbers have.

if query view, huge list of {productid: null} pairs.

i've used list, doesn't homecoming things value null, seems need rebuilding every time view updated. add together 1 value, , goes through building whole list. it's starting take quite long time, , seems it'll go on take longer database grows in size.

is there way homecoming id's of view don't have null values? (like not null sql). or, know best practice situation?

couchdb

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -