国产三级农村妇女在线,国产精品毛片a∨一区二区三区,国产乱子伦视频大全,国产精品色拉拉,国产欧美日韩一区二区三区,

首頁 > 技術(shù) > 數(shù)據(jù)庫

MongoDB快速上手指南: 使用 Mocha 編寫測試 “Test Driven Development”

數(shù)據(jù)庫 2022-12-07 20:14:07

Mocha 是一個 js 測試的包, 編寫測試有兩個關(guān)鍵字 describeit

  • 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

作者:是小梁同學呀
來源:稀土掘金

TAg

加載中~

本網(wǎng)站LOGO受版權(quán)及商標保護,版權(quán)登記號:國作登字-2022-F-10126915,未經(jīng)湖南木星科技官方許可,嚴禁使用。
Copyright ? 2012-2022 湖南木星科技有限公司(木星網(wǎng))版權(quán)所有
轉(zhuǎn)載內(nèi)容版權(quán)歸作者及來源網(wǎng)站所有,本站原創(chuàng)內(nèi)容轉(zhuǎn)載請注明來源,商業(yè)媒體及紙媒請先聯(lián)系:aishangyiwan@126.com

工信部備案號:湘ICP備19012813號-5