Can someone tell me how can i ask data from MangoDB perticular directory lets say ‘testing’ rather then whole database which have all original data. I want data on postman from test directory. The i have tried for connection is following:-
router.get(‘/get_company_ids’, async (req, res) => {
try {
const companies = await Company.find({}, { _id: 1 }); here i found the company
const companyIds = companies.map(company => company._id); here mapping all company id's
res.json({ company_ids: companyIds });
} catch (err) {
res.status(500).json({ error: err.message });
});
sagar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.