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

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -