mongoose 7.6.0 → 7.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/query.js CHANGED
@@ -1680,7 +1680,7 @@ Query.prototype.setOptions = function(options, overwrite) {
1680
1680
 
1681
1681
  const printRawResultDeprecationWarning = util.deprecate(
1682
1682
  function printRawResultDeprecationWarning() {},
1683
- 'The `rawResult` option for Mongoose queries is deprecated. Use `includeResultMetadata: false` as a replacement for `rawResult: true`.'
1683
+ 'The `rawResult` option for Mongoose queries is deprecated. Use `includeResultMetadata: true` as a replacement for `rawResult: true`.'
1684
1684
  );
1685
1685
 
1686
1686
  /*!
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mongoose",
3
3
  "description": "Mongoose MongoDB ODM",
4
- "version": "7.6.0",
4
+ "version": "7.6.1",
5
5
  "author": "Guillermo Rauch <guillermo@learnboost.com>",
6
6
  "keywords": [
7
7
  "mongodb",
@@ -19,7 +19,7 @@
19
19
  ],
20
20
  "license": "MIT",
21
21
  "dependencies": {
22
- "bson": "^5.4.0",
22
+ "bson": "^5.5.0",
23
23
  "kareem": "2.5.1",
24
24
  "mongodb": "5.9.0",
25
25
  "mpath": "0.9.0",
@@ -39,7 +39,6 @@
39
39
  "axios": "1.1.3",
40
40
  "babel-loader": "8.2.5",
41
41
  "benchmark": "2.1.4",
42
- "bluebird": "3.7.2",
43
42
  "broken-link-checker": "^0.7.8",
44
43
  "buffer": "^5.6.0",
45
44
  "cheerio": "1.0.0-rc.12",
@@ -130,14 +129,6 @@
130
129
  },
131
130
  "homepage": "https://mongoosejs.com",
132
131
  "browser": "./dist/browser.umd.js",
133
- "mocha": {
134
- "extension": [
135
- "test.js"
136
- ],
137
- "watch-files": [
138
- "test/**/*.js"
139
- ]
140
- },
141
132
  "config": {
142
133
  "mongodbMemoryServer": {
143
134
  "disablePostinstall": true
package/types/models.d.ts CHANGED
@@ -32,7 +32,9 @@ declare module 'mongoose' {
32
32
  PopulateOption,
33
33
  SessionOption {
34
34
  limit?: number;
35
+ // @deprecated, use includeResultMetadata instead
35
36
  rawResult?: boolean;
37
+ includeResultMetadata?: boolean;
36
38
  ordered?: boolean;
37
39
  lean?: boolean;
38
40
  throwOnValidationError?: boolean;
package/types/query.d.ts CHANGED
@@ -124,9 +124,14 @@ declare module 'mongoose' {
124
124
  overwriteDiscriminatorKey?: boolean;
125
125
  projection?: ProjectionType<DocType>;
126
126
  /**
127
+ * @deprecated use includeResultMetadata instead.
127
128
  * if true, returns the raw result from the MongoDB driver
128
129
  */
129
130
  rawResult?: boolean;
131
+ /**
132
+ * if ture, includes meta data for the result from the MongoDB driver
133
+ */
134
+ includeResultMetadata?: boolean;
130
135
  readPreference?: string | mongodb.ReadPreferenceMode;
131
136
  /**
132
137
  * An alias for the `new` option. `returnOriginal: false` is equivalent to `new: true`.
package/.eslintrc.js DELETED
@@ -1,236 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- extends: [
5
- 'eslint:recommended'
6
- ],
7
- ignorePatterns: [
8
- 'tools',
9
- 'dist',
10
- 'website.js',
11
- 'test/files/*',
12
- 'benchmarks',
13
- '*.min.js',
14
- '**/docs/js/native.js',
15
- '!.*',
16
- 'node_modules',
17
- '.git'
18
- ],
19
- overrides: [
20
- {
21
- files: [
22
- '**/*.{ts,tsx}',
23
- '**/*.md/*.ts',
24
- '**/*.md/*.typescript'
25
- ],
26
- extends: [
27
- 'plugin:@typescript-eslint/eslint-recommended',
28
- 'plugin:@typescript-eslint/recommended'
29
- ],
30
- plugins: [
31
- '@typescript-eslint'
32
- ],
33
- rules: {
34
- '@typescript-eslint/triple-slash-reference': 'off',
35
- '@typescript-eslint/no-non-null-assertion': 'off',
36
- '@typescript-eslint/no-empty-function': 'off',
37
- 'spaced-comment': [
38
- 'error',
39
- 'always',
40
- {
41
- block: {
42
- markers: [
43
- '!'
44
- ],
45
- balanced: true
46
- },
47
- markers: [
48
- '/'
49
- ]
50
- }
51
- ],
52
- '@typescript-eslint/no-explicit-any': 'off',
53
- '@typescript-eslint/ban-types': 'off',
54
- '@typescript-eslint/no-unused-vars': 'off',
55
- '@typescript-eslint/explicit-module-boundary-types': 'off',
56
- '@typescript-eslint/indent': [
57
- 'warn',
58
- 2,
59
- {
60
- SwitchCase: 1,
61
- ignoredNodes: ['TSTypeParameterInstantiation']
62
- }
63
- ],
64
- '@typescript-eslint/prefer-optional-chain': 'error',
65
- '@typescript-eslint/brace-style': 'error',
66
- '@typescript-eslint/no-dupe-class-members': 'error',
67
- '@typescript-eslint/no-redeclare': 'error',
68
- '@typescript-eslint/type-annotation-spacing': 'error',
69
- '@typescript-eslint/object-curly-spacing': [
70
- 'error',
71
- 'always'
72
- ],
73
- '@typescript-eslint/semi': 'error',
74
- '@typescript-eslint/space-before-function-paren': [
75
- 'error',
76
- 'never'
77
- ],
78
- '@typescript-eslint/space-infix-ops': 'off'
79
- }
80
- },
81
- {
82
- files: [
83
- '**/docs/js/**/*.js'
84
- ],
85
- env: {
86
- node: false,
87
- browser: true
88
- }
89
- }
90
- // // eslint-plugin-markdown has been disabled because of out-standing issues, see https://github.com/eslint/eslint-plugin-markdown/issues/214
91
- // {
92
- // files: ['**/*.md'],
93
- // processor: 'markdown/markdown'
94
- // },
95
- // {
96
- // files: ['**/*.md/*.js', '**/*.md/*.javascript', '**/*.md/*.ts', '**/*.md/*.typescript'],
97
- // parserOptions: {
98
- // ecmaFeatures: {
99
- // impliedStrict: true
100
- // },
101
- // sourceType: 'module', // required to allow "import" statements
102
- // ecmaVersion: 'latest' // required to allow top-level await
103
- // },
104
- // rules: {
105
- // 'no-undef': 'off',
106
- // 'no-unused-expressions': 'off',
107
- // 'no-unused-vars': 'off',
108
- // 'no-redeclare': 'off',
109
- // '@typescript-eslint/no-redeclare': 'off'
110
- // }
111
- // }
112
- ],
113
- plugins: [
114
- 'mocha-no-only'
115
- // 'markdown'
116
- ],
117
- parserOptions: {
118
- ecmaVersion: 2020
119
- },
120
- env: {
121
- node: true,
122
- es6: true,
123
- es2020: true
124
- },
125
- rules: {
126
- 'comma-style': 'error',
127
- indent: [
128
- 'error',
129
- 2,
130
- {
131
- SwitchCase: 1,
132
- VariableDeclarator: 2
133
- }
134
- ],
135
- 'keyword-spacing': 'error',
136
- 'no-whitespace-before-property': 'error',
137
- 'no-buffer-constructor': 'warn',
138
- 'no-console': 'off',
139
- 'no-constant-condition': 'off',
140
- 'no-multi-spaces': 'error',
141
- 'func-call-spacing': 'error',
142
- 'no-trailing-spaces': 'error',
143
- 'no-undef': 'error',
144
- 'no-unneeded-ternary': 'error',
145
- 'no-const-assign': 'error',
146
- 'no-useless-rename': 'error',
147
- 'no-dupe-keys': 'error',
148
- 'space-in-parens': [
149
- 'error',
150
- 'never'
151
- ],
152
- 'spaced-comment': [
153
- 'error',
154
- 'always',
155
- {
156
- block: {
157
- markers: [
158
- '!'
159
- ],
160
- balanced: true
161
- }
162
- }
163
- ],
164
- 'key-spacing': [
165
- 'error',
166
- {
167
- beforeColon: false,
168
- afterColon: true
169
- }
170
- ],
171
- 'comma-spacing': [
172
- 'error',
173
- {
174
- before: false,
175
- after: true
176
- }
177
- ],
178
- 'array-bracket-spacing': 1,
179
- 'arrow-spacing': [
180
- 'error',
181
- {
182
- before: true,
183
- after: true
184
- }
185
- ],
186
- 'object-curly-spacing': [
187
- 'error',
188
- 'always'
189
- ],
190
- 'comma-dangle': [
191
- 'error',
192
- 'never'
193
- ],
194
- 'no-unreachable': 'error',
195
- quotes: [
196
- 'error',
197
- 'single'
198
- ],
199
- 'quote-props': [
200
- 'error',
201
- 'as-needed'
202
- ],
203
- semi: 'error',
204
- 'no-extra-semi': 'error',
205
- 'semi-spacing': 'error',
206
- 'no-spaced-func': 'error',
207
- 'no-throw-literal': 'error',
208
- 'space-before-blocks': 'error',
209
- 'space-before-function-paren': [
210
- 'error',
211
- 'never'
212
- ],
213
- 'space-infix-ops': 'error',
214
- 'space-unary-ops': 'error',
215
- 'no-var': 'warn',
216
- 'prefer-const': 'warn',
217
- strict: [
218
- 'error',
219
- 'global'
220
- ],
221
- 'no-restricted-globals': [
222
- 'error',
223
- {
224
- name: 'context',
225
- message: 'Don\'t use Mocha\'s global context'
226
- }
227
- ],
228
- 'no-prototype-builtins': 'off',
229
- 'mocha-no-only/mocha-no-only': [
230
- 'error'
231
- ],
232
- 'no-empty': 'off',
233
- 'eol-last': 'warn',
234
- 'no-multiple-empty-lines': ['warn', { max: 2 }]
235
- }
236
- };
@@ -1,69 +0,0 @@
1
- 'use strict';
2
- // this file is named ".cjs" instead of ".js" because markdownlint-cli2 only looks for ".cjs" or ".mjs"
3
-
4
- // use aliases instead of "MD000" naming
5
-
6
- module.exports = {
7
- ignores: [
8
- // the following are ignored because they are just redirects
9
- 'History.md',
10
- 'SECURITY.md',
11
- 'migrating_to_5.md', // this does not affect "docs/migrating_to_5.md"
12
-
13
- // ignored for now, but should be changes later
14
- '.github/PULL_REQUEST_TEMPLATE.md',
15
-
16
- // ignore changelog because it uses different heading style than other documents and older versions use different formatting
17
- 'CHANGELOG.md',
18
-
19
- // exclude node_modules because it isnt excluded by default
20
- 'node_modules'
21
- ]
22
- };
23
-
24
- module.exports.config = {
25
- // disable default rules
26
- default: false,
27
-
28
- // alt-text for images
29
- accessibility: true,
30
- // consistent blank lines
31
- blank_lines: true,
32
- // consistent unordered lists
33
- bullet: { style: 'asterisk' },
34
- // consistent and read-able code
35
- code: true,
36
- // consistent emphasis characters
37
- emphasis: { style: 'asterisk' },
38
- // ensure consistent header usage
39
- headers: { style: 'atx' },
40
- // ensure consistent "hr" usage
41
- hr: { style: '---' },
42
- // disable disalloing html tags, because
43
- // mongoose currently uses html tags directly for heading ID's and style
44
- html: false,
45
- // consistent indentation
46
- indentation: true,
47
- // consistent links and good links
48
- links: true,
49
- // enabled by "links"
50
- // mongoose currently does not wrap plain links in "<>"
51
- 'no-bare-urls': false,
52
- // consistent ordered lists
53
- ol: true,
54
- // consistent whitespace usage
55
- whitespace: true
56
-
57
- // atx: undefined, // covered by "headers"
58
- // atx_closed: undefined, // covered by "headers"
59
- // blockquote: true, // covered by "whitespace"
60
- // hard_tab: undefined, // covered by "whitespace"
61
- // headings: undefined, // covered by "headers"
62
- // images: true, // covered by "accessibility" and "links"
63
- // language: undefined, // covered by "code"
64
- // line_length: undefined, // mongoose currently uses a mix of max-line-length and relying on editor auto-wrap
65
- // spaces: undefined, // covered by "atx", "atx_closed", "headers"
66
- // spelling: undefined, // mongoose currently only uses short-form language specifiers and so does not need this
67
- // ul: undefined, // covered by "whitespace" and "bullet"
68
- // url: undefined, // covered by "links"
69
- };
package/.mocharc.yml DELETED
@@ -1,4 +0,0 @@
1
- reporter: spec # better to identify failing / slow tests than "dot"
2
- ui: bdd # explicitly setting, even though it is mocha default
3
- require:
4
- - test/mocha-fixtures.js
package/lgtm.yml DELETED
@@ -1,12 +0,0 @@
1
- path_classifiers:
2
- src:
3
- - lib
4
- types:
5
- - types
6
- test:
7
- - test
8
- docs:
9
- - docs
10
- queries:
11
- - exclude: "*"
12
- - include: lib
@@ -1,18 +0,0 @@
1
- 'use strict';
2
-
3
- const config = require('../webpack.config.js');
4
- const webpack = require('webpack');
5
-
6
- const compiler = webpack(config);
7
-
8
- console.log('Starting browser build...');
9
- compiler.run((err, stats) => {
10
- if (err) {
11
- console.err(stats.toString());
12
- console.err('Browser build unsuccessful.');
13
- process.exit(1);
14
- }
15
- console.log(stats.toString());
16
- console.log('Browser build successful.');
17
- process.exit(0);
18
- });
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- const { execSync } = require('child_process');
4
- const { name, version } = require('../package.json');
5
-
6
- execSync('npm pack');
7
- execSync(`mv ${name}-${version}.tgz ${name}.tgz`);
@@ -1,161 +0,0 @@
1
- 'use strict';
2
-
3
- let config;
4
- try {
5
- config = require('../.config.js');
6
- } finally {
7
- if (!config || !config.uri) {
8
- console.error('No Config or config.URI given, please create a .config.js file with those values in the root of the repository');
9
- process.exit(-1);
10
- }
11
- }
12
- const cheerio = require('cheerio');
13
- const docsFilemap = require('../docs/source');
14
- const fs = require('fs');
15
- const pug = require('pug');
16
- const mongoose = require('../');
17
- let { version } = require('../package.json');
18
-
19
- const { marked: markdown } = require('marked');
20
- const highlight = require('highlight.js');
21
- markdown.setOptions({
22
- highlight: function(code) {
23
- return highlight.highlight(code, { language: 'JavaScript' }).value;
24
- }
25
- });
26
-
27
- // 5.13.5 -> 5.x, 6.8.2 -> 6.x, etc.
28
- version = version.slice(0, version.indexOf('.')) + '.x';
29
-
30
- const contentSchema = new mongoose.Schema({
31
- title: { type: String, required: true },
32
- body: { type: String, required: true },
33
- url: { type: String, required: true },
34
- version: { type: String, required: true, default: version },
35
- versionNumber: { type: Number, required: true, default: version.replace(/\.x$/, '') }
36
- });
37
- contentSchema.index({ title: 'text', body: 'text' });
38
- const Content = mongoose.model('Content', contentSchema, 'Content');
39
-
40
- const contents = [];
41
-
42
- for (const [filename, file] of Object.entries(docsFilemap.fileMap)) {
43
- if (file.api) {
44
- for (const prop of file.props) {
45
- const content = new Content({
46
- title: `API: ${prop.name}`,
47
- body: prop.description,
48
- url: `${filename}#${prop.anchorId}`
49
- });
50
- const err = content.validateSync();
51
- if (err != null) {
52
- console.error(content);
53
- throw err;
54
- }
55
- contents.push(content);
56
- }
57
- } else if (file.markdown) {
58
- let text = fs.readFileSync(filename, 'utf8');
59
- text = markdown.parse(text);
60
-
61
- const content = new Content({
62
- title: file.title,
63
- body: text,
64
- url: filename.replace('.md', '.html').replace(/^docs/, '')
65
- });
66
-
67
- content.validateSync();
68
-
69
- const $ = cheerio.load(text);
70
-
71
- contents.push(content);
72
-
73
- // Break up individual h3's into separate content for more fine grained search
74
- $('h3').each((index, el) => {
75
- el = $(el);
76
- const title = el.text();
77
- const html = el.nextUntil('h3').html();
78
- const content = new Content({
79
- title: `${file.title}: ${title}`,
80
- body: html,
81
- url: `${filename.replace('.md', '.html').replace(/^docs/, '')}#${el.prop('id')}`
82
- });
83
-
84
- content.validateSync();
85
- contents.push(content);
86
- });
87
- } else if (file.guide) {
88
- let text = fs.readFileSync(filename, 'utf8');
89
- text = text.substr(text.indexOf('block content') + 'block content\n'.length);
90
- text = pug.render(`div\n${text}`, { filters: { markdown }, filename });
91
-
92
- const content = new Content({
93
- title: file.title,
94
- body: text,
95
- url: filename.replace('.pug', '.html').replace(/^docs/, '')
96
- });
97
-
98
- content.validateSync();
99
-
100
- const $ = cheerio.load(text);
101
-
102
- contents.push(content);
103
-
104
- // Break up individual h3's into separate content for more fine grained search
105
- $('h3').each((index, el) => {
106
- el = $(el);
107
- const title = el.text();
108
- const html = el.nextUntil('h3').html();
109
- const content = new Content({
110
- title: `${file.title}: ${title}`,
111
- body: html,
112
- url: `${filename.replace('.pug', '.html').replace(/^docs/, '')}#${el.prop('id')}`
113
- });
114
-
115
- content.validateSync();
116
- contents.push(content);
117
- });
118
- }
119
- }
120
-
121
- run().catch(async error => {
122
- console.error(error.stack);
123
-
124
- // ensure the script exists in case of error
125
- await mongoose.disconnect();
126
- });
127
-
128
- async function run() {
129
- await mongoose.connect(config.uri, { dbName: 'mongoose', serverSelectionTimeoutMS: 5000 });
130
-
131
- // wait for the index to be created
132
- await Content.init();
133
-
134
- await Content.deleteMany({ version });
135
- let count = 0;
136
- for (const content of contents) {
137
- if (version === '7.x') {
138
- let url = content.url.startsWith('/') ? content.url : `/${content.url}`;
139
- if (!url.startsWith('/docs')) {
140
- url = '/docs' + url;
141
- }
142
- content.url = url;
143
- } else {
144
- const url = content.url.startsWith('/') ? content.url : `/${content.url}`;
145
- content.url = `/docs/${version}/docs${url}`;
146
- }
147
- console.log(`${++count} / ${contents.length}`);
148
- await content.save();
149
- }
150
-
151
- const results = await Content.
152
- find({ $text: { $search: 'validate' }, version }, { score: { $meta: 'textScore' } }).
153
- sort({ score: { $meta: 'textScore' } }).
154
- limit(10);
155
-
156
- console.log(results.map(res => res.url));
157
-
158
- console.log(`Added ${contents.length} Content`);
159
-
160
- process.exit(0);
161
- }
@@ -1,115 +0,0 @@
1
- 'use strict';
2
-
3
- let config;
4
- try {
5
- config = require('../.config.js');
6
- } finally {
7
- if (!config || !config.uri) {
8
- console.error('No Config or config.URI given, please create a .config.js file with those values in the root of the repository');
9
- process.exit(-1);
10
- }
11
- }
12
- const axios = require('axios');
13
- const fs = require('fs');
14
- const mongoose = require('../');
15
-
16
- run().catch(err => {
17
- console.error(err);
18
- process.exit(-1);
19
- });
20
-
21
- // only "." because fs resolves relative to the CWD instead of relative to __dirname
22
- const docsDir = './docs';
23
-
24
- async function run() {
25
- await mongoose.connect(config.uri);
26
-
27
- const Subscriber = mongoose.model('Subscriber', mongoose.Schema({
28
- companyName: String,
29
- description: String,
30
- url: String,
31
- logo: String
32
- }), 'Subscriber');
33
-
34
- const Job = mongoose.model('Job', mongoose.Schema({
35
- logo: String,
36
- company: String,
37
- title: String,
38
- location: {
39
- type: String,
40
- required: true
41
- },
42
- description: {
43
- type: String,
44
- required: true
45
- },
46
- url: {
47
- type: String,
48
- required: true
49
- }
50
- }), 'Job');
51
-
52
- const OpenCollectiveSponsor = mongoose.model('OpenCollectiveSponsor', mongoose.Schema({
53
- openCollectiveId: {
54
- type: Number,
55
- required: true
56
- },
57
- website: {
58
- type: String,
59
- required: true
60
- },
61
- image: {
62
- type: String,
63
- required: true
64
- },
65
- alt: {
66
- type: String
67
- }
68
- }), 'OpenCollectiveSponsor');
69
-
70
- try {
71
- fs.mkdirSync(`${docsDir}/data`);
72
- } catch (err) {}
73
-
74
- const subscribers = await Subscriber.
75
- find({ companyName: { $exists: true }, description: { $exists: true }, logo: { $exists: true } }).
76
- sort({ createdAt: 1 }).
77
- select({ companyName: 1, description: 1, url: 1, logo: 1 });
78
- fs.writeFileSync(`${docsDir}/data/sponsors.json`, JSON.stringify(subscribers, null, ' '));
79
-
80
- const jobs = await Job.find().select({ logo: 1, company: 1, title: 1, location: 1, description: 1, url: 1 });
81
- fs.writeFileSync(`${docsDir}/data/jobs.json`, JSON.stringify(jobs, null, ' '));
82
-
83
- const opencollectiveSponsors = await axios.get('https://opencollective.com/mongoose/members.json').
84
- then(res => res.data).
85
- then(sponsors => {
86
- return sponsors.filter(result => result.tier == 'sponsor' && result.isActive);
87
- }).
88
- catch(() => null);
89
-
90
- for (const sponsor of opencollectiveSponsors) {
91
- const override = await OpenCollectiveSponsor.findOne({ openCollectiveId: sponsor['MemberId'] });
92
- if (override == null) {
93
- continue;
94
- }
95
-
96
- sponsor.website = override.website;
97
- sponsor.image = override.image;
98
- if (override.alt != null) {
99
- sponsor.alt = override.alt;
100
- }
101
- }
102
-
103
- const additionalSponsors = await OpenCollectiveSponsor.find({}).
104
- then(docs => docs.filter(doc => doc.openCollectiveId == null));
105
- for (const sponsor of additionalSponsors) {
106
- opencollectiveSponsors.push(sponsor);
107
- }
108
-
109
- if (opencollectiveSponsors != null) {
110
- fs.writeFileSync(`${docsDir}/data/opencollective.json`, JSON.stringify(opencollectiveSponsors, null, ' '));
111
- }
112
-
113
- console.log('Done');
114
- process.exit(0);
115
- }
@@ -1,15 +0,0 @@
1
- 'use strict';
2
-
3
- const fs = require('fs');
4
-
5
- const stdin = fs.readFileSync(0).toString('utf8');
6
- const maxInstantiations = isNaN(process.argv[2]) ? 120000 : parseInt(process.argv[2], 10);
7
-
8
- console.log(stdin);
9
-
10
- const numInstantiations = parseInt(stdin.match(/Instantiations:\s+(\d+)/)[1], 10);
11
- if (numInstantiations > maxInstantiations) {
12
- throw new Error(`Instantiations ${numInstantiations} > max ${maxInstantiations}`);
13
- }
14
-
15
- process.exit(0);
package/tools/auth.js DELETED
@@ -1,31 +0,0 @@
1
- 'use strict';
2
-
3
- const Server = require('mongodb-topology-manager').Server;
4
- const mongodb = require('mongodb');
5
-
6
- run().catch(error => {
7
- console.error(error);
8
- process.exit(-1);
9
- });
10
-
11
- async function run() {
12
- // Create new instance
13
- const server = new Server('mongod', {
14
- auth: null,
15
- dbpath: '/data/db/27017'
16
- });
17
-
18
- // Purge the directory
19
- await server.purge();
20
-
21
- // Start process
22
- await server.start();
23
-
24
- const db = await mongodb.MongoClient.connect('mongodb://127.0.0.1:27017/admin');
25
-
26
- await db.addUser('passwordIsTaco', 'taco', {
27
- roles: ['dbOwner']
28
- });
29
-
30
- console.log('done');
31
- }
package/tools/repl.js DELETED
@@ -1,35 +0,0 @@
1
- 'use strict';
2
-
3
- run().catch(error => {
4
- console.error(error);
5
- process.exit(-1);
6
- });
7
-
8
- async function run() {
9
- const ReplSet = require('mongodb-memory-server').MongoMemoryReplSet;
10
-
11
- // Create new instance
12
- const replSet = new ReplSet({
13
- binary: {
14
- version: process.argv[2]
15
- },
16
- instanceOpts: [
17
- // Set the expiry job in MongoDB to run every second
18
- {
19
- port: 27017,
20
- args: ['--setParameter', 'ttlMonitorSleepSecs=1']
21
- }
22
- ],
23
- dbName: 'mongoose_test',
24
- replSet: {
25
- name: 'rs0',
26
- count: 2,
27
- storageEngine: 'wiredTiger'
28
- }
29
- });
30
-
31
- await replSet.start();
32
- await replSet.waitUntilRunning();
33
- console.log('MongoDB-ReplicaSet is now running.');
34
- console.log(replSet.getUri('mongoose_test'));
35
- }
package/tools/sharded.js DELETED
@@ -1,46 +0,0 @@
1
- 'use strict';
2
-
3
- run().catch(error => {
4
- console.error(error);
5
- process.exit(-1);
6
- });
7
-
8
-
9
- async function run() {
10
- const Sharded = require('mongodb-topology-manager').Sharded;
11
-
12
- // Create new instance
13
- const topology = new Sharded({
14
- mongod: 'mongod',
15
- mongos: 'mongos'
16
- });
17
-
18
- await topology.addShard([{
19
- options: {
20
- bind_ip: '127.0.0.1', port: 31000, dbpath: '/data/db/31000', shardsvr: null
21
- }
22
- }], { replSet: 'rs1' });
23
-
24
- await topology.addConfigurationServers([{
25
- options: {
26
- bind_ip: '127.0.0.1', port: 35000, dbpath: '/data/db/35000'
27
- }
28
- }], { replSet: 'rs0' });
29
-
30
- await topology.addProxies([{
31
- bind_ip: '127.0.0.1', port: 51000, configdb: '127.0.0.1:35000'
32
- }], {
33
- binary: 'mongos'
34
- });
35
-
36
- console.log('Start...');
37
- // Start up topology
38
- await topology.start();
39
-
40
- console.log('Started');
41
-
42
- // Shard db
43
- await topology.enableSharding('test');
44
-
45
- console.log('done');
46
- }
package/tsconfig.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "strict": true,
4
- "strictNullChecks": true,
5
- "paths": {
6
- "mongoose" : ["./types/index.d.ts"]
7
- }
8
- }
9
- }