MongoDB快速上手指南: 使用 Mocha 编写测试 “Test Driven Development”
Mocha 是一个 js 测试的包, 编写测试有两个关键字 describe 和 it
Mocha 是一个 js 测试的包, 编写测试有两个关键字 describe
和 it
describe
是一个”统领块”, 所有的 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
作者:是小梁同学呀
来源:稀土掘金
相关文章
- MongoDB5.0 新特性“时序”解析:集合性能 VS IOT 场景设计
- MongoDB快速上手指南:SpringBoot整合MongoDB
- MongoDB快速上手指南:MongoDB 的索引
- MongoDB快速上手指南:文档间的对应关系一对一、一对多、多对多
- MongoDB快速上手指南:数据库操作常用命令CRUD
- MongoDB快速上手指南:业务场景、三高特点及相关概念
- mongodb基础知识:什么是文档型数据库?
- MongoDB性能监控与其他数据库对比
- Mongodb环配置文件详解:启动、安装…进入shell环境界面
- MongoDB 入门教程:开发环境搭建及 Node.js 和 Java 的读写访问