I’ve got this problem since your last update.
Expected behavior
I’ve created a new project called lereacteur-team
. I’ve created a custom route in ./api/users.js
where I have a simple route in order to get users:
const express = require("express");
const router = express.Router();
const users = require("../models/users");
router.get(
"/api/users", async (req, res) => {
try {
const Users = await users.find();
res.status(200).json(Users);
} catch (e) {
console.log(e);
return "Error";
}
},
);
module.exports = router;
Actual behavior
I’ve got this error: TypeError: users.find is not a function
when I request my route.
Here is my users
model:
module.exports = (mongoose, Mongoose) => {
const schema = Mongoose.Schema(
{
firstname: String,
lastname: String,
},
{
timestamps: false,
},
);
return mongoose.model("users", schema, "users");
};
Setup
"body-parser": "1.19.0",
"chalk": "~1.1.3",
"cookie-parser": "1.4.4",
"cors": "2.8.5",
"debug": "~4.0.1",
"dotenv": "~6.1.0",
"express": "~4.17.1",
"express-jwt": "5.3.1",
"forest-express-mongoose": "^7.0.1",
"mongoose": "~5.8.2",
"morgan": "1.9.1",
"require-all": "^3.0.0"