MongoDB query criteria not working correctly Meteor / JavaScript -
i have products collection attribute called "productcode". trying write server-side query return product based on productcode attribute, keep getting "cannot read property 'propertycode' of undefined" error.
here method call:
meteor.call('findproduct', searchval, function(error, a) { if(error) { alert(error.reason) } else { console.log('search success!'); } });
here methods.js code giving me error:
'findproduct': function(searchval, a) { = products.findone({productcode: searchval}); return a; //return product of interest }
error: exception in delivering result of invoking 'findproduct': typeerror: cannot read property 'productcode' of undefined
however, if hard code in product code, works:
'findproduct': function(searchval, a) { = products.findone({productcode: 9021073}); return a; //this return product }
in terminal console, works well:
db.products.findone({productcode: 291105300});
any ideas might doing wrong?
ah - reason string. converted integer using parseint , worked!
Comments
Post a Comment