MongoDB快速上手指南: 使用 Mocha 編寫測試 “Test Driven Development”
Mocha 是一個 js 測試的包, 編寫測試有兩個關(guān)鍵字 describe
和 it
describe
是一個”統(tǒng)領(lǐng)塊”, 所有的 test functions 都會在它”名下”it
表示每一個 test function
create_test.jsconst assert = require('assert')// assume we have a User model defined in src/user.jsconst User = require('../src/user')// after installing Mocha, we have global access// to describe and it keywordsdescribe('Creating records', () => { it('saves a user', () => {const joe = new User({ name: "Joe" }); joe.save();assert() }); });復制代碼
NoSQL Databases
Benefits of NoSQL
- Easy for inserting and retrieving data, since they are contained in one block, in one json object
- Flexible schema, if a new attribute added, it is easy to just add / append to the object
- Scalability, horizontally partition the data (availability > consistency)
- Aggregation, find metrics and etc
Drawbacks of NoSQL
- Update = Delete + Insert, not built for update
- Not consistent, ACID is not guaranteed, do not support transactions
- Not read optimized. Read entire block find the attribute. But SQL, just need one column (read time compartively slow)
- Relations are not implicit
- JOINS are hard to accomplish, all manually
作者:是小梁同學呀
來源:稀土掘金
版權(quán)聲明:
本站所有文章和圖片均來自用戶分享和網(wǎng)絡(luò)收集,文章和圖片版權(quán)歸原作者及原出處所有,僅供學習與參考,請勿用于商業(yè)用途,如果損害了您的權(quán)利,請聯(lián)系網(wǎng)站客服處理。