@abhimanusharma/mern-crud-app 中文文档教程
Simple crud apis for simple CRM.
CRM 使用 express router 和 mongodb 进行数据库操作。 要更新或获取配置值,请参阅根位置中的 .env 文件。
Directory Structure
- controllers/
- clientsController.js
- leadsController.js
- salesController.js
- models/
- client.js
- lead.js
- sale.js
- routes/
- clientRouter.js
- index.js
- leadRouter.js
- saleRouter.js
- views/
- public/
- src/
- components/
- Client.js
- Sale.js
- Lead.js
- App.js
- App.css
- index.js
- index.css
- components/
- package.json
- app.js
- package.json
- README.md
- .env
.env file
MONGO_DB_URL=mongodb://<hostname>:<mongodb-port-number>/<dbname>
SERVER_PORT=<server-port-number>
New route
创建新的路由文件后,将其包含到 routes/index.js
Run the app
要运行该应用程序,请确保您在本地安装了 nodejs 和 mongodb。 运行 npm install
以安装所有依赖项。 运行 npm run dev
以运行应用程序
Mongodb database
在本地计算机或 VM 或 docker 上安装 mongodb 后,在其中创建一个数据库。 在终端中运行命令 mongo
。 然后运行 use
,其中 dbname 是您的数据库的名称。 更新 .env 文件 MONGODBURL 变量中的数据库名称。
Simple crud apis for simple CRM.
CRM is using express router and mongodb for database operations. To update or get configuration values refer .env file in the root location.
Directory Structure
- controllers/
- clientsController.js
- leadsController.js
- salesController.js
- models/
- client.js
- lead.js
- sale.js
- routes/
- clientRouter.js
- index.js
- leadRouter.js
- saleRouter.js
- views/
- public/
- src/
- components/
- Client.js
- Sale.js
- Lead.js
- App.js
- App.css
- index.js
- index.css
- components/
- package.json
- app.js
- package.json
- README.md
- .env
.env file
MONGO_DB_URL=mongodb://<hostname>:<mongodb-port-number>/<dbname>
SERVER_PORT=<server-port-number>
New route
After creating new route file include it into routes/index.js
Run the app
To run the applcation make sure you have nodejs and mongodb installed locally. Run npm install
to install all the dependencies. Run npm run dev
to run the application
Mongodb database
After installing mongodb on your local machine or VM or docker create a database in it. Run command mongo
in the terminal. Then run use <dbname>
where dbname is the name of your databse. Update the databse name in the .env file MONGODBURL variable.