node.js - mongoose find not work as expected - null result -
i have started search google , in stackoverflow.com can not solve this.
when use:
suppliers.find({}, function(err, supplier) {
get suppliers mongodb.
but when call following returns: {"suppliers":[]} , not suppliers smaid (for examples: 1) show.
suppliers.find({ "smaid": req.params.supplierid }, function(err, supplier) {
here following complete code schema understand problem (give not on result when search smaid).
router.get('/:supplierid', function(req, res) { suppliers = conn.model('suppliers') suppliers.find({ "smaid": req.params.supplierid }, function(err, supplier) { if (err) { return res.sendstatus(500) } if (!supplier) { return res.sendstatus(404) } res.send({ suppliers: supplier }) }) })
the schema
var schema = require('mongoose').schema var suppliersschema = new schema( { smaid: string , companyname: string , companynametwo: string , street: string , city: string , zipcode: string , country: string , telefon: string , telefax: string , emailadress: string , erstkontaktemail: string , lieferungenan: string , website: string , cat: string }, { collection : 'suppliers' }
)
please me. greetings sven.
Comments
Post a Comment