节点快速猫鼬目录结构最佳实践



我为快速应用程序找到了这个库结构,但是对于猫鼬,模型库有不同的用途。我把我的计划放在哪里?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)...

最新更新