Skip to content

Commit 5cafc11

Browse files
docs: explaining clearly how to install non latest binary + toc added (#321)
* docs: explaining clearly how to install non latest binary + toc added * docs: cleaner explanation
1 parent d405997 commit 5cafc11

File tree

2 files changed

+46
-4
lines changed

2 files changed

+46
-4
lines changed

README.md

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
This package spins up an actual/real MongoDB server programmatically from node, for testing or mocking during development. By default it holds the data in memory. A fresh spun up `mongod` process takes about 7Mb of memory. The server will allow you to connect your favorite ODM or client library to the MongoDB server and run integration tests isolated from each other.
1010

11-
On install, this package downloads the latest MongoDB binaries and saves them to a cache folder.
11+
On install, this [package downloads](#configuring-which-mongod-binary-to-use) the latest MongoDB binaries and saves them to a cache folder.
1212

1313
On starting a new instance of the memory server, if the binary cannot be found, it will be auto-downloaded, thus the first run may take some time. All further runs will be fast, because they will use the downloaded binaries.
1414

@@ -20,6 +20,39 @@ Every `MongoMemoryServer` instance creates and starts a fresh MongoDB server on
2020

2121
Works perfectly [with Travis CI](https://github.com/nodkz/graphql-compose-mongoose/commit/7a6ac2de747d14281f9965f418065e97a57cfb37) without additional `services` and `addons` options in `.travis.yml`.
2222

23+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
24+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
25+
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
26+
27+
- [Installation](#installation)
28+
- [Requirements](#requirements)
29+
- [Known Incompatibilities](#known-incompatibilities)
30+
- [mongodb-memory-server](#mongodb-memory-server)
31+
- [mongodb-memory-server-global](#mongodb-memory-server-global)
32+
- [mongodb-memory-server-core](#mongodb-memory-server-core)
33+
- [Configuring which mongod binary to use](#configuring-which-mongod-binary-to-use)
34+
- [Usage](#usage)
35+
- [Simple server start](#simple-server-start)
36+
- [Available options for MongoMemoryServer](#available-options-for-mongomemoryserver)
37+
- [Replica Set start](#replica-set-start)
38+
- [Available options for MongoMemoryReplSet](#available-options-for-mongomemoryreplset)
39+
- [Options which can be set via ENVIRONMENT variables](#options-which-can-be-set-via-environment-variables)
40+
- [Options which can be set via package.json's `config` section](#options-which-can-be-set-via-packagejsons-config-section)
41+
- [Simple test with MongoClient](#simple-test-with-mongoclient)
42+
- [Provide connection string to mongoose](#provide-connection-string-to-mongoose)
43+
- [Several mongoose connections simultaneously](#several-mongoose-connections-simultaneously)
44+
- [Simple Mocha/Chai test example](#simple-mochachai-test-example)
45+
- [Simple Jest test example](#simple-jest-test-example)
46+
- [AVA test runner](#ava-test-runner)
47+
- [Docker Alpine](#docker-alpine)
48+
- [Enable Debug Mode](#enable-debug-mode)
49+
- [Travis](#travis)
50+
- [Credits](#credits)
51+
- [License](#license)
52+
- [Maintainers](#maintainers)
53+
54+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
55+
2356
## Installation
2457

2558
This tool provides three packages for different purposes:
@@ -46,7 +79,7 @@ And one of those:
4679
- ArchLinux & Alpine do not have an offical mongodb build
4780
- ArchLinux(Docker) does not have an `/etc/os-release` file by default
4881

49-
### `mongodb-memory-server`
82+
### mongodb-memory-server
5083

5184
Auto-downloads the latest `mongod` binary on npm install to: `node_modules/.cache/mongodb-binaries`.
5285

@@ -56,7 +89,7 @@ yarn add mongodb-memory-server --dev
5689
npm install mongodb-memory-server --save-dev
5790
```
5891

59-
### `mongodb-memory-server-global`
92+
### mongodb-memory-server-global
6093

6194
Auto-downloads the latest `mongod` binary on npm install to: `%HOME%/.cache/mongodb-binaries` / `~/.cache/mongodb-binaries`.
6295

@@ -66,7 +99,7 @@ yarn add mongodb-memory-server-global --dev
6699
npm install mongodb-memory-server-global --save-dev
67100
```
68101

69-
### `mongodb-memory-server-core`
102+
### mongodb-memory-server-core
70103

71104
Does NOT auto-download `mongod` on npm install.
72105

@@ -78,6 +111,14 @@ npm install mongodb-memory-server-core --save-dev
78111

79112
_Note: the package does try to download `mongod` upon server start if it cannot find the binary._
80113

114+
### Configuring which mongod binary to use
115+
The default behaviour is that the latest version for your OS will be downloaded. By setting [ENVIRONMENT variables](#options-which-can-be-set-via-environment-variables) you are able to specify which version and binary will be downloaded:
116+
117+
```bash
118+
export MONGOMS_DOWNLOAD_URL=https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1804-4.2.8.tgz
119+
export MONGOMS_VERSION=4.2.8
120+
```
121+
81122
## Usage
82123

83124
### Simple server start

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"jest": "jest --env node",
3636
"build": "tsc --build tsconfig.build.json",
3737
"release": "lerna publish --conventional-commits",
38+
"readme:toc": "npx doctoc ./README.md",
3839
"postinstall": "yarn build"
3940
}
4041
}

0 commit comments

Comments
 (0)