我是怎么構建Node.js程序的

我是怎么構建Node.js程序的

用README.md代替shuoming
數(shù)據(jù)庫中的models和collections分別代表什么?以mysql為例,ORM中的
如何創(chuàng)建API
集成測試:單元測試的邏輯擴展

/
api/
bin/
collections/
config/
controllers/
env/
lib/
models/
public/
routes/
test/
views/
.gitignore
.jshintrc
app.js
package.json
README.md

README.md

  • 項目名和描述
  • 軟件要求
  • 依賴
  • Getting started instructions
  • 需求配置
  • 任務命令
  • 風格指南
  • 應用架構
  • 路由/API
  • License信息

./models/mymodel.js

// get config

var config = require('../config');

// connect to the database

var Bookshelf = require('../lib/dbconnect')(config);

// define model

var myModel = Bookshelf.Model.extend({  
    tableName: 'items'
});

// export collection module
module.exports = myModel;

./collections/mycollection.js

//require the model for this collection
var myModel = require('../models/mymodel');
// define collection
var myCollection = Bookshelf.Collection.extend({
  model: myModel
});
// export collection module
module.exports = myCollection;

./controllers/items.js

./routes/items.js

./config

./env

最后編輯于
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容