📜  node js express mongodb 查找所有文档 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:02:27.035000             🧑  作者: Mango

代码示例1
//to get all the products
app.get("/products", async (req, res) => {
  try {
    const allProducts = await Product.find();
    return res.json(allProducts);
  } catch (error) {
    res.json({ message: error });
  }
});