When I query the following it returns: {"suppliers":[]}
But it must return all suppliers that contains this smaId. Please help me.
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
, 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' }
)