This error is what I find. user is not allowed to do action
MongoServerError: user is not allowed to do action [remove] on [shoeDatabase.users],
import express from "express";
import User from "./Models/UserModel.js";
import users from "./data/users.js";
const ImportData = express.Router();
ImportData.post("/user", async (req, res) => {
await User.remove({});
const importUser = await User.insertMany(users);
res.send({ importUser });
});
export default ImportData;
solution for your error is :
userthere are other problems to address:
await User.remove({});will remove all present users... are you sure?usersoriginated from? (should be parsed from req and are not)