簡體   English   中英

Node express mongoose 目錄結構最佳實踐

[英]Node express mongoose directory structure best practices

我為 express 應用找到了這個庫結構,但是對於 mongoose,模型庫有不同的用途。 我把我的計划放在哪里? https://www.terlici.com/2014/08/25/best-practices-express-structure.html

project/
  controllers/
    comments.js
    index.js
    users.js
  helpers/
    dates.js
  middlewares/
    auth.js
    users.js
  models/
    comment.js
    user.js
  public/
    libs/
    css/
    img/
  views/
    comments/
      comment.jade
    users/
    index.jade
  tests/
    controllers/
    models/
      comment.js
    middlewares/
    integration/
    ui/
  .gitignore
  app.js
  package.json

您將架構放在模型文件夾中。使用貓鼬,您可以在其文件中為每個架構創建模型,然后導出模型。 您還可以在同一文件中導出一些對您的模型進行操作的函數,例如 Model.findAll()、Model.findById(id) ...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM