fixed JSDoc, updated @seald-io/binary-search-tree & devDeps, fixed linting, regenerated docs

pull/32/head
Timothée Rebours 2 years ago
parent 558fa7e335
commit ecd8d11e10
  1. 9
      API.md
  2. 9
      CHANGELOG.md
  3. 4
      README.md
  4. 14
      benchmarks/commonUtilities.js
  5. 2
      benchmarks/update.js
  6. 2
      lib/datastore.js
  7. 2
      lib/indexes.js
  8. 4
      lib/persistence.js
  9. 2
      lib/storage.js
  10. 8
      lib/utils.js
  11. 30901
      package-lock.json
  12. 45
      package.json
  13. 34
      test/browser/nedb-browser.spec.js
  14. 4
      test/cursor.async.test.js
  15. 72
      test/cursor.test.js
  16. 8
      test/db.async.test.js
  17. 392
      test/db.test.js
  18. 18
      test/executor.test.js
  19. 12
      test/persistence.test.js
  20. 2
      test/utils.test.js
  21. 2
      webpack.config.js

@ -337,6 +337,8 @@ don't care.</p>
- [.compareStrings] [<code>compareStrings</code>](#compareStrings) - <p>If specified, it overrides default string comparison which is not - [.compareStrings] [<code>compareStrings</code>](#compareStrings) - <p>If specified, it overrides default string comparison which is not
well adapted to non-US characters in particular accented letters. Native <code>localCompare</code> will most of the time be well adapted to non-US characters in particular accented letters. Native <code>localCompare</code> will most of the time be
the right choice.</p> the right choice.</p>
- [.testSerializationHooks] <code>boolean</code> <code> = true</code> - <p>Whether to test the serialization hooks or not,
might be CPU-intensive</p>
<a name="Datastore+inMemoryOnly"></a> <a name="Datastore+inMemoryOnly"></a>
@ -501,7 +503,7 @@ preferable to instantiate a new one.</p>
**Params** **Params**
- options <code>object</code> - options <code>object</code>
- .fieldName <code>string</code> - .fieldName <code>string</code> | <code>Array.&lt;string&gt;</code>
- [.unique] <code>boolean</code> <code> = false</code> - [.unique] <code>boolean</code> <code> = false</code>
- [.sparse] <code>boolean</code> <code> = false</code> - [.sparse] <code>boolean</code> <code> = false</code>
- [.expireAfterSeconds] <code>number</code> - [.expireAfterSeconds] <code>number</code>
@ -518,8 +520,8 @@ executor.</p>
**Params** **Params**
- options <code>object</code> - options <code>object</code>
- .fieldName <code>string</code> - <p>Name of the field to index. Use the dot notation to index a field in a nested - .fieldName <code>string</code> | <code>Array.&lt;string&gt;</code> - <p>Name of the field to index. Use the dot notation to index a field in a nested
document.</p> document. For a compound index, use an array of field names. Using a comma in a field name is not permitted.</p>
- [.unique] <code>boolean</code> <code> = false</code> - <p>Enforce field uniqueness. Note that a unique index will raise an error - [.unique] <code>boolean</code> <code> = false</code> - <p>Enforce field uniqueness. Note that a unique index will raise an error
if you try to index two documents for which the field is not defined.</p> if you try to index two documents for which the field is not defined.</p>
- [.sparse] <code>boolean</code> <code> = false</code> - <p>Don't index documents for which the field is not defined. Use this option - [.sparse] <code>boolean</code> <code> = false</code> - <p>Don't index documents for which the field is not defined. Use this option
@ -840,6 +842,7 @@ with <code>appendfsync</code> option set to <code>no</code>.</p>
- [.modes] <code>object</code> - <p>Modes to use for FS permissions. Will not work on Windows.</p> - [.modes] <code>object</code> - <p>Modes to use for FS permissions. Will not work on Windows.</p>
- [.fileMode] <code>number</code> <code> = 0o644</code> - <p>Mode to use for files.</p> - [.fileMode] <code>number</code> <code> = 0o644</code> - <p>Mode to use for files.</p>
- [.dirMode] <code>number</code> <code> = 0o755</code> - <p>Mode to use for directories.</p> - [.dirMode] <code>number</code> <code> = 0o755</code> - <p>Mode to use for directories.</p>
- [.testSerializationHooks] <code>boolean</code> <code> = true</code> - <p>Whether to test the serialization hooks or not, might be CPU-intensive</p>
<a name="Persistence+compactDatafile"></a> <a name="Persistence+compactDatafile"></a>

@ -6,6 +6,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres and this project adheres
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [4.0.0] - 2023-01-19
### Added
- \[**BREAKING**\] Implement compound indexes [#27](https://github.com/seald/nedb/pull/27). Commas (`,`) can no longer be used in indexed field names.
### Updated
- Updated [@seald-io/binary-search-tree](https://github.com/seald/binary-search-tree) to `v1.0.3`.
- Updated dev dependencies, including `standard@17.0.0` which changed some linting rules.
- Updated API docs.
## [3.1.0] - 2022-09-02 ## [3.1.0] - 2022-09-02
### Added ### Added
- Added a `testSerializationHooks` option which defaults to `true`. Setting to `false` allows to skip the test of the hooks, which may be slow. - Added a `testSerializationHooks` option which defaults to `true`. Setting to `false` allows to skip the test of the hooks, which may be slow.

@ -29,7 +29,7 @@ const Datastore = require('@seald-io/nedb')
## Documentation ## Documentation
The API is a subset of MongoDB's API (the most used operations). The API is a subset of MongoDB's API (the most used operations).
Since version [3.0.0](./CHANGELOG.md#300---unreleased), NeDB provides a Promise-based equivalent for each function Since version [3.0.0](./CHANGELOG.md#300---2022-03-16), NeDB provides a Promise-based equivalent for each function
which is suffixed with `Async`, for example `loadDatabaseAsync`. which is suffixed with `Async`, for example `loadDatabaseAsync`.
The original callback-based interface is still available, fully retro-compatible The original callback-based interface is still available, fully retro-compatible
@ -698,7 +698,7 @@ fields in nested documents using the dot notation. For now, indexes are only
used to speed up basic queries and queries using `$in`, `$lt`, `$lte`, `$gt` used to speed up basic queries and queries using `$in`, `$lt`, `$lte`, `$gt`
and `$gte`. The indexed values cannot be of type array of object. and `$gte`. The indexed values cannot be of type array of object.
**Breaking change**: [since v3.2.0](./CHANGELOG.md), comma can no longer be used in indexed field names. **Breaking change**: [since v4.0.0](./CHANGELOG.md#400---2023-01-19), commas (`,`) can no longer be used in indexed field names.
The following is illegal: The following is illegal:
```javascript ```javascript

@ -39,7 +39,7 @@ module.exports.getConfiguration = function (benchDb) {
inMemoryOnly: program.inMemory inMemoryOnly: program.inMemory
}) })
return { n: n, d: d, program: program } return { n, d, program }
} }
/** /**
@ -96,7 +96,7 @@ module.exports.insertDocs = function (d, n, profiler, cb) {
return cb() return cb()
} }
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.insert({ docNumber: order[i] }, function (err) { d.insert({ docNumber: order[i] }, function (err) {
executeAsap(function () { executeAsap(function () {
runFrom(i + 1) runFrom(i + 1)
@ -122,7 +122,7 @@ module.exports.findDocs = function (d, n, profiler, cb) {
return cb() return cb()
} }
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.find({ docNumber: order[i] }, function (err, docs) { d.find({ docNumber: order[i] }, function (err, docs) {
if (docs.length !== 1 || docs[0].docNumber !== order[i]) { return cb(new Error('One find didnt work')) } if (docs.length !== 1 || docs[0].docNumber !== order[i]) { return cb(new Error('One find didnt work')) }
executeAsap(function () { executeAsap(function () {
@ -159,7 +159,7 @@ module.exports.findDocsWithIn = function (d, n, profiler, cb) {
return cb() return cb()
} }
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.find({ docNumber: { $in: ins[i] } }, function (err, docs) { d.find({ docNumber: { $in: ins[i] } }, function (err, docs) {
if (docs.length !== arraySize) { return cb(new Error('One find didnt work')) } if (docs.length !== arraySize) { return cb(new Error('One find didnt work')) }
executeAsap(function () { executeAsap(function () {
@ -186,7 +186,7 @@ module.exports.findOneDocs = function (d, n, profiler, cb) {
return cb() return cb()
} }
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.findOne({ docNumber: order[i] }, function (err, doc) { d.findOne({ docNumber: order[i] }, function (err, doc) {
if (!doc || doc.docNumber !== order[i]) { return cb(new Error('One find didnt work')) } if (!doc || doc.docNumber !== order[i]) { return cb(new Error('One find didnt work')) }
executeAsap(function () { executeAsap(function () {
@ -250,7 +250,7 @@ module.exports.removeDocs = function (options, d, n, profiler, cb) {
d.remove({ docNumber: order[i] }, options, function (err, nr) { d.remove({ docNumber: order[i] }, options, function (err, nr) {
if (err) { return cb(err) } if (err) { return cb(err) }
if (nr !== 1) { return cb(new Error('One remove didnt work')) } if (nr !== 1) { return cb(new Error('One remove didnt work')) }
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.insert({ docNumber: order[i] }, function (err) { // We need to reinsert the doc so that we keep the collection's size at n d.insert({ docNumber: order[i] }, function (err) { // We need to reinsert the doc so that we keep the collection's size at n
// So actually we're calculating the average time taken by one insert + one remove // So actually we're calculating the average time taken by one insert + one remove
executeAsap(function () { executeAsap(function () {
@ -276,7 +276,7 @@ module.exports.loadDatabase = function (d, n, profiler, cb) {
return cb() return cb()
} }
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.loadDatabase(function (err) { d.loadDatabase(function (err) {
executeAsap(function () { executeAsap(function () {
runFrom(i + 1) runFrom(i + 1)

@ -25,7 +25,7 @@ waterfall([
apply(commonUtilities.updateDocs, { multi: false }, d, n, profiler), apply(commonUtilities.updateDocs, { multi: false }, d, n, profiler),
// Test with multiple documents // Test with multiple documents
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
function (cb) { d.remove({}, { multi: true }, function (err) { return cb() }) }, function (cb) { d.remove({}, { multi: true }, function (err) { return cb() }) },
apply(commonUtilities.insertDocs, d, n, profiler), apply(commonUtilities.insertDocs, d, n, profiler),
function (cb) { profiler.step('MULTI: TRUE'); return cb() }, function (cb) { profiler.step('MULTI: TRUE'); return cb() },

@ -682,7 +682,7 @@ class Datastore extends EventEmitter {
else expiredDocsIds.push(doc._id) else expiredDocsIds.push(doc._id)
}) })
for (const _id of expiredDocsIds) { for (const _id of expiredDocsIds) {
await this._removeAsync({ _id: _id }, {}) await this._removeAsync({ _id }, {})
} }
} else validDocs.push(...docs) } else validDocs.push(...docs)
return validDocs return validDocs

@ -73,7 +73,7 @@ class Index {
* Options object given to the underlying BinarySearchTree. * Options object given to the underlying BinarySearchTree.
* @type {{unique: boolean, checkValueEquality: (function(*, *): boolean), compareKeys: ((function(*, *, compareStrings): (number|number))|*)}} * @type {{unique: boolean, checkValueEquality: (function(*, *): boolean), compareKeys: ((function(*, *, compareStrings): (number|number))|*)}}
*/ */
this.treeOptions = { unique: this.unique, compareKeys: model.compareThings, checkValueEquality: checkValueEquality } this.treeOptions = { unique: this.unique, compareKeys: model.compareThings, checkValueEquality }
/** /**
* Underlying BinarySearchTree for this index. Uses an AVLTree for optimization. * Underlying BinarySearchTree for this index. Uses an AVLTree for optimization.

@ -221,7 +221,7 @@ class Persistence {
const tdata = Object.values(dataById) const tdata = Object.values(dataById)
return { data: tdata, indexes: indexes } return { data: tdata, indexes }
} }
/** /**
@ -280,7 +280,7 @@ class Persistence {
} }
const data = Object.values(dataById) const data = Object.values(dataById)
resolve({ data, indexes: indexes }) resolve({ data, indexes })
}) })
lineStream.on('error', function (err) { lineStream.on('error', function (err) {

@ -195,7 +195,7 @@ const flushToStorageAsync = async (options) => {
*/ */
const writeFileLinesAsync = (filename, lines, mode = DEFAULT_FILE_MODE) => new Promise((resolve, reject) => { const writeFileLinesAsync = (filename, lines, mode = DEFAULT_FILE_MODE) => new Promise((resolve, reject) => {
try { try {
const stream = writeFileStream(filename, { mode: mode }) const stream = writeFileStream(filename, { mode })
const readable = Readable.from(lines) const readable = Readable.from(lines)
readable.on('data', (line) => { readable.on('data', (line) => {
try { try {

@ -59,11 +59,11 @@ const isDate = d => isObject(d) && Object.prototype.toString.call(d) === '[objec
const isRegExp = re => isObject(re) && Object.prototype.toString.call(re) === '[object RegExp]' const isRegExp = re => isObject(re) && Object.prototype.toString.call(re) === '[object RegExp]'
/** /**
* return a copy of the object that filtered using the given keys * Return a copy of the object filtered using the given keys.
* *
* @param {*} object * @param {object} object
* @param {*} keys * @param {string[]} keys
* @returns * @return {object}
*/ */
const pick = (object, keys) => { const pick = (object, keys) => {
return keys.reduce((obj, key) => { return keys.reduce((obj, key) => {

30901
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -27,6 +27,10 @@
"name": "Eliot Akira", "name": "Eliot Akira",
"email": "me@eliotakira.com", "email": "me@eliotakira.com",
"url": "https://eliotakira.com/" "url": "https://eliotakira.com/"
},
{
"name": " Loïc Hermann",
"email": "loic.hermann@outlook.fr"
} }
], ],
"description": "File-based embedded data store for node.js", "description": "File-based embedded data store for node.js",
@ -41,40 +45,41 @@
"url": "git@github.com:seald/nedb.git" "url": "git@github.com:seald/nedb.git"
}, },
"dependencies": { "dependencies": {
"@seald-io/binary-search-tree": "^1.0.2", "@seald-io/binary-search-tree": "^1.0.3",
"localforage": "^1.9.0", "localforage": "^1.9.0",
"util": "^0.12.4" "util": "^0.12.4"
}, },
"devDependencies": { "devDependencies": {
"@react-native-async-storage/async-storage": "^1.15.9", "@react-native-async-storage/async-storage": "^1.17.11",
"@types/jest": "^27.0.2", "@types/jest": "^27.5.2",
"browser-resolve": "^2.0.0", "browser-resolve": "^2.0.0",
"chai": "^4.3.4", "chai": "^4.3.7",
"commander": "^7.2.0", "commander": "^7.2.0",
"events": "^3.3.0", "events": "^3.3.0",
"jest": "^27.3.1", "jest": "^27.5.1",
"jsdoc-to-markdown": "^7.1.0", "jsdoc-to-markdown": "^8.0.0",
"karma": "^6.3.2", "karma": "^6.4.1",
"karma-chai": "^0.1.0", "karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.1.0", "karma-chrome-launcher": "^3.1.1",
"karma-junit-reporter": "^2.0.1", "karma-junit-reporter": "^2.0.1",
"karma-mocha": "^2.0.1", "karma-mocha": "^2.0.1",
"karma-source-map-support": "^1.4.0", "karma-source-map-support": "^1.4.0",
"mocha": "^9.1.3", "mocha": "^10.2.0",
"mocha-junit-reporter": "^2.0.0", "mocha-junit-reporter": "^2.2.0",
"path-browserify": "^1.0.1", "path-browserify": "^1.0.1",
"process": "^0.11.10", "process": "^0.11.10",
"react-native": "^0.66.0", "react": "^18.2.0",
"semver": "^7.3.5", "react-native": "^0.71.0",
"source-map-loader": "^2.0.2", "semver": "^7.3.8",
"standard": "^16.0.3", "source-map-loader": "^4.0.1",
"terser-webpack-plugin": "^5.1.2", "standard": "^17.0.0",
"terser-webpack-plugin": "^5.3.6",
"timers-browserify": "^2.0.12", "timers-browserify": "^2.0.12",
"ts-jest": "^27.0.7", "ts-jest": "^27.1.5",
"ts-node": "^10.3.0", "ts-node": "^10.9.1",
"typescript": "^4.4.4", "typescript": "^4.9.4",
"webpack": "^5.37.0", "webpack": "^5.75.0",
"webpack-cli": "^4.7.0", "webpack-cli": "^5.0.1",
"xvfb-maybe": "^0.2.1" "xvfb-maybe": "^0.2.1"
}, },
"scripts": { "scripts": {

@ -97,16 +97,16 @@ describe('Basic CRUD functionality', function () {
it('Updating documents', function (done) { it('Updating documents', function (done) {
const db = new Nedb() const db = new Nedb()
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
db.insert({ planet: 'Eaaaaarth' }, function (err, newDoc1) { db.insert({ planet: 'Eaaaaarth' }, function (err, newDoc1) {
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
db.insert({ planet: 'Maaaaars' }, function (err, newDoc2) { db.insert({ planet: 'Maaaaars' }, function (err, newDoc2) {
// Simple update // Simple update
db.update({ _id: newDoc2._id }, { $set: { planet: 'Saturn' } }, {}, function (err, nr) { db.update({ _id: newDoc2._id }, { $set: { planet: 'Saturn' } }, {}, function (err, nr) {
assert.isNull(err) assert.isNull(err)
assert.strictEqual(nr, 1) assert.strictEqual(nr, 1)
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
db.find({}, function (err, docs) { db.find({}, function (err, docs) {
assert.strictEqual(docs.length, 2) assert.strictEqual(docs.length, 2)
assert.strictEqual(findById(docs, newDoc1._id).planet, 'Eaaaaarth') assert.strictEqual(findById(docs, newDoc1._id).planet, 'Eaaaaarth')
@ -117,7 +117,7 @@ describe('Basic CRUD functionality', function () {
assert.isNull(err) assert.isNull(err)
assert.strictEqual(nr, 0) assert.strictEqual(nr, 0)
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
db.find({}, function (err, docs) { db.find({}, function (err, docs) {
assert.strictEqual(docs.length, 2) assert.strictEqual(docs.length, 2)
assert.strictEqual(findById(docs, newDoc1._id).planet, 'Eaaaaarth') assert.strictEqual(findById(docs, newDoc1._id).planet, 'Eaaaaarth')
@ -128,7 +128,7 @@ describe('Basic CRUD functionality', function () {
assert.isNull(err) assert.isNull(err)
assert.strictEqual(nr, 1) assert.strictEqual(nr, 1)
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
db.find({}, function (err, docs) { db.find({}, function (err, docs) {
assert.strictEqual(docs.length, 2) assert.strictEqual(docs.length, 2)
assert.strictEqual(findById(docs, newDoc1._id).planet, 'Uranus') assert.strictEqual(findById(docs, newDoc1._id).planet, 'Uranus')
@ -139,7 +139,7 @@ describe('Basic CRUD functionality', function () {
assert.isNull(err) assert.isNull(err)
assert.strictEqual(nr, 2) assert.strictEqual(nr, 2)
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
db.find({}, function (err, docs) { db.find({}, function (err, docs) {
assert.strictEqual(docs.length, 2) assert.strictEqual(docs.length, 2)
assert.strictEqual(findById(docs, newDoc1._id).planet, 'Uranus') assert.strictEqual(findById(docs, newDoc1._id).planet, 'Uranus')
@ -163,14 +163,14 @@ describe('Basic CRUD functionality', function () {
it('Updating documents: special modifiers', function (done) { it('Updating documents: special modifiers', function (done) {
const db = new Nedb() const db = new Nedb()
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
db.insert({ planet: 'Earth' }, function (err, newDoc1) { db.insert({ planet: 'Earth' }, function (err, newDoc1) {
// Pushing to an array // Pushing to an array
db.update({}, { $push: { satellites: 'Phobos' } }, {}, function (err, nr) { db.update({}, { $push: { satellites: 'Phobos' } }, {}, function (err, nr) {
assert.isNull(err) assert.isNull(err)
assert.strictEqual(nr, 1) assert.strictEqual(nr, 1)
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
db.findOne({}, function (err, doc) { db.findOne({}, function (err, doc) {
assert.deepStrictEqual(doc, { planet: 'Earth', _id: newDoc1._id, satellites: ['Phobos'] }) assert.deepStrictEqual(doc, { planet: 'Earth', _id: newDoc1._id, satellites: ['Phobos'] })
@ -178,7 +178,7 @@ describe('Basic CRUD functionality', function () {
assert.isNull(err) assert.isNull(err)
assert.strictEqual(nr, 1) assert.strictEqual(nr, 1)
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
db.findOne({}, function (err, doc) { db.findOne({}, function (err, doc) {
assert.deepStrictEqual(doc, { planet: 'Earth', _id: newDoc1._id, satellites: ['Phobos', 'Deimos'] }) assert.deepStrictEqual(doc, { planet: 'Earth', _id: newDoc1._id, satellites: ['Phobos', 'Deimos'] })
@ -200,7 +200,7 @@ describe('Basic CRUD functionality', function () {
assert.strictEqual(upsert.b, 1) assert.strictEqual(upsert.b, 1)
assert.strictEqual(nr, 1) assert.strictEqual(nr, 1)
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
db.find({}, function (err, docs) { db.find({}, function (err, docs) {
assert.strictEqual(docs.length, 1) assert.strictEqual(docs.length, 1)
assert.strictEqual(docs[0].a, 4) assert.strictEqual(docs[0].a, 4)
@ -223,7 +223,7 @@ describe('Basic CRUD functionality', function () {
assert.isNull(err) assert.isNull(err)
assert.strictEqual(nr, 2) assert.strictEqual(nr, 2)
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
db.find({}, function (err, docs) { db.find({}, function (err, docs) {
assert.strictEqual(docs.length, 1) assert.strictEqual(docs.length, 1)
assert.strictEqual(docs[0].a, 2) assert.strictEqual(docs[0].a, 2)
@ -233,7 +233,7 @@ describe('Basic CRUD functionality', function () {
assert.isNull(err) assert.isNull(err)
assert.strictEqual(nr, 0) assert.strictEqual(nr, 0)
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
db.find({}, function (err, docs) { db.find({}, function (err, docs) {
assert.strictEqual(docs.length, 1) assert.strictEqual(docs.length, 1)
assert.strictEqual(docs[0].a, 2) assert.strictEqual(docs[0].a, 2)
@ -243,7 +243,7 @@ describe('Basic CRUD functionality', function () {
assert.isNull(err) assert.isNull(err)
assert.strictEqual(nr, 1) assert.strictEqual(nr, 1)
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
db.find({}, function (err, docs) { db.find({}, function (err, docs) {
assert.strictEqual(docs.length, 0) assert.strictEqual(docs.length, 0)
@ -264,7 +264,7 @@ describe('Indexing', function () {
db.insert({ a: 4 }, function () { db.insert({ a: 4 }, function () {
db.insert({ a: 6 }, function () { db.insert({ a: 6 }, function () {
db.insert({ a: 7 }, function () { db.insert({ a: 7 }, function () {
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
testUtils.callbackify(query => db._getCandidatesAsync(query))({ a: 6 }, function (err, candidates) { testUtils.callbackify(query => db._getCandidatesAsync(query))({ a: 6 }, function (err, candidates) {
assert.strictEqual(candidates.length, 3) assert.strictEqual(candidates.length, 3)
assert.isDefined(candidates.find(function (doc) { return doc.a === 4 })) assert.isDefined(candidates.find(function (doc) { return doc.a === 4 }))
@ -273,7 +273,7 @@ describe('Indexing', function () {
db.ensureIndex({ fieldName: 'a' }) db.ensureIndex({ fieldName: 'a' })
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
testUtils.callbackify(query => db._getCandidatesAsync(query))({ a: 6 }, function (err, candidates) { testUtils.callbackify(query => db._getCandidatesAsync(query))({ a: 6 }, function (err, candidates) {
assert.strictEqual(candidates.length, 1) assert.strictEqual(candidates.length, 1)
assert.isDefined(candidates.find(function (doc) { return doc.a === 6 })) assert.isDefined(candidates.find(function (doc) { return doc.a === 6 }))
@ -311,7 +311,7 @@ describe("Don't forget to launch persistence tests!", function () {
const filename = 'test' const filename = 'test'
before('Clean & write', function (done) { before('Clean & write', function (done) {
const db = new Nedb({ filename: filename, autoload: true }) const db = new Nedb({ filename, autoload: true })
db.remove({}, { multi: true }, function () { db.remove({}, { multi: true }, function () {
db.insert({ hello: 'world' }, function (err) { db.insert({ hello: 'world' }, function (err) {
assert.isNull(err) assert.isNull(err)
@ -321,7 +321,7 @@ describe("Don't forget to launch persistence tests!", function () {
}) })
it('Read & check', function (done) { it('Read & check', function (done) {
const db = new Nedb({ filename: filename, autoload: true }) const db = new Nedb({ filename, autoload: true })
db.find({}, (err, docs) => { db.find({}, (err, docs) => {
assert.isNull(err) assert.isNull(err)
if (docs.length !== 1) { if (docs.length !== 1) {

@ -277,7 +277,7 @@ describe('Cursor Async', function () {
await d.insertAsync({ name: 'henry', other: 4 }) await d.insertAsync({ name: 'henry', other: 4 })
const cursor = new Cursor(d, {}) const cursor = new Cursor(d, {})
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
const docs = await cursor.sort({ other: 1 }) const docs = await cursor.sort({ other: 1 })
assert.equal(docs.length, 4) assert.equal(docs.length, 4)
assert.equal(docs[0].name, 'sue') assert.equal(docs[0].name, 'sue')
@ -320,7 +320,7 @@ describe('Cursor Async', function () {
await d.insertAsync({ name: 'zoe', age: 23, nid: 4 }) await d.insertAsync({ name: 'zoe', age: 23, nid: 4 })
await d.insertAsync({ name: 'jako', age: 35, nid: 5 }) await d.insertAsync({ name: 'jako', age: 35, nid: 5 })
const cursor = new Cursor(d, {}) const cursor = new Cursor(d, {})
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
const docs = await cursor.sort({ name: 1, age: -1 }) const docs = await cursor.sort({ name: 1, age: -1 })
assert.equal(docs.length, 5) assert.equal(docs.length, 5)

@ -40,15 +40,15 @@ describe('Cursor', function () {
describe('Without sorting', function () { describe('Without sorting', function () {
beforeEach(function (done) { beforeEach(function (done) {
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.insert({ age: 5 }, function (err) { d.insert({ age: 5 }, function (err) {
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.insert({ age: 57 }, function (err) { d.insert({ age: 57 }, function (err) {
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.insert({ age: 52 }, function (err) { d.insert({ age: 52 }, function (err) {
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.insert({ age: 23 }, function (err) { d.insert({ age: 23 }, function (err) {
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.insert({ age: 89 }, function (err) { d.insert({ age: 89 }, function (err) {
return done() return done()
}) })
@ -152,15 +152,15 @@ describe('Cursor', function () {
describe('Sorting of the results', function () { describe('Sorting of the results', function () {
beforeEach(function (done) { beforeEach(function (done) {
// We don't know the order in which docs wil be inserted but we ensure correctness by testing both sort orders // We don't know the order in which docs wil be inserted but we ensure correctness by testing both sort orders
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.insert({ age: 5 }, function (err) { d.insert({ age: 5 }, function (err) {
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.insert({ age: 57 }, function (err) { d.insert({ age: 57 }, function (err) {
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.insert({ age: 52 }, function (err) { d.insert({ age: 52 }, function (err) {
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.insert({ age: 23 }, function (err) { d.insert({ age: 23 }, function (err) {
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.insert({ age: 89 }, function (err) { d.insert({ age: 89 }, function (err) {
return done() return done()
}) })
@ -204,14 +204,14 @@ describe('Cursor', function () {
db.insert({ name: 'charlie' }) db.insert({ name: 'charlie' })
db.insert({ name: 'zulu' }) db.insert({ name: 'zulu' })
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
db.find({}).sort({ name: 1 }).exec(function (err, docs) { db.find({}).sort({ name: 1 }).exec(function (err, docs) {
docs.map(x => x.name)[0].should.equal('zulu') docs.map(x => x.name)[0].should.equal('zulu')
docs.map(x => x.name)[1].should.equal('alpha') docs.map(x => x.name)[1].should.equal('alpha')
docs.map(x => x.name)[2].should.equal('charlie') docs.map(x => x.name)[2].should.equal('charlie')
delete db.compareStrings delete db.compareStrings
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
db.find({}).sort({ name: 1 }).exec(function (err, docs) { db.find({}).sort({ name: 1 }).exec(function (err, docs) {
docs.map(x => x.name)[0].should.equal('alpha') docs.map(x => x.name)[0].should.equal('alpha')
docs.map(x => x.name)[1].should.equal('charlie') docs.map(x => x.name)[1].should.equal('charlie')
@ -416,7 +416,7 @@ describe('Cursor', function () {
}, },
function (cb) { function (cb) {
const cursor = new Cursor(d, {}) const cursor = new Cursor(d, {})
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
cursor.sort({ name: 1 }).exec(function (err, docs) { cursor.sort({ name: 1 }).exec(function (err, docs) {
docs.length.should.equal(3) docs.length.should.equal(3)
docs[0].name.should.equal('jakeb') docs[0].name.should.equal('jakeb')
@ -427,7 +427,7 @@ describe('Cursor', function () {
}, },
function (cb) { function (cb) {
const cursor = new Cursor(d, {}) const cursor = new Cursor(d, {})
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
cursor.sort({ name: -1 }).exec(function (err, docs) { cursor.sort({ name: -1 }).exec(function (err, docs) {
docs.length.should.equal(3) docs.length.should.equal(3)
docs[0].name.should.equal('sue') docs[0].name.should.equal('sue')
@ -449,13 +449,13 @@ describe('Cursor', function () {
d.remove({}, { multi: true }, function (err) { d.remove({}, { multi: true }, function (err) {
if (err) { return cb(err) } if (err) { return cb(err) }
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.insert({ event: { recorded: new Date(400) } }, function (err, _doc1) { d.insert({ event: { recorded: new Date(400) } }, function (err, _doc1) {
doc1 = _doc1 doc1 = _doc1
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.insert({ event: { recorded: new Date(60000) } }, function (err, _doc2) { d.insert({ event: { recorded: new Date(60000) } }, function (err, _doc2) {
doc2 = _doc2 doc2 = _doc2
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.insert({ event: { recorded: new Date(32) } }, function (err, _doc3) { d.insert({ event: { recorded: new Date(32) } }, function (err, _doc3) {
doc3 = _doc3 doc3 = _doc3
return cb() return cb()
@ -466,7 +466,7 @@ describe('Cursor', function () {
}, },
function (cb) { function (cb) {
const cursor = new Cursor(d, {}) const cursor = new Cursor(d, {})
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
cursor.sort({ 'event.recorded': 1 }).exec(function (err, docs) { cursor.sort({ 'event.recorded': 1 }).exec(function (err, docs) {
docs.length.should.equal(3) docs.length.should.equal(3)
docs[0]._id.should.equal(doc3._id) docs[0]._id.should.equal(doc3._id)
@ -477,7 +477,7 @@ describe('Cursor', function () {
}, },
function (cb) { function (cb) {
const cursor = new Cursor(d, {}) const cursor = new Cursor(d, {})
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
cursor.sort({ 'event.recorded': -1 }).exec(function (err, docs) { cursor.sort({ 'event.recorded': -1 }).exec(function (err, docs) {
docs.length.should.equal(3) docs.length.should.equal(3)
docs[0]._id.should.equal(doc2._id) docs[0]._id.should.equal(doc2._id)
@ -508,7 +508,7 @@ describe('Cursor', function () {
}, },
function (cb) { function (cb) {
const cursor = new Cursor(d, {}) const cursor = new Cursor(d, {})
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
cursor.sort({ other: 1 }).exec(function (err, docs) { cursor.sort({ other: 1 }).exec(function (err, docs) {
docs.length.should.equal(4) docs.length.should.equal(4)
docs[0].name.should.equal('sue') docs[0].name.should.equal('sue')
@ -524,7 +524,7 @@ describe('Cursor', function () {
}, },
function (cb) { function (cb) {
const cursor = new Cursor(d, { name: { $in: ['suzy', 'jakeb', 'jako'] } }) const cursor = new Cursor(d, { name: { $in: ['suzy', 'jakeb', 'jako'] } })
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
cursor.sort({ other: -1 }).exec(function (err, docs) { cursor.sort({ other: -1 }).exec(function (err, docs) {
docs.length.should.equal(2) docs.length.should.equal(2)
docs[0].name.should.equal('jakeb') docs[0].name.should.equal('jakeb')
@ -554,7 +554,7 @@ describe('Cursor', function () {
}, },
function (cb) { function (cb) {
const cursor = new Cursor(d, {}) const cursor = new Cursor(d, {})
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
cursor.sort({ other: 1 }).exec(function (err, docs) { cursor.sort({ other: 1 }).exec(function (err, docs) {
docs.length.should.equal(3) docs.length.should.equal(3)
return cb() return cb()
@ -562,7 +562,7 @@ describe('Cursor', function () {
}, },
function (cb) { function (cb) {
const cursor = new Cursor(d, { name: { $in: ['sue', 'jakeb', 'jakob'] } }) const cursor = new Cursor(d, { name: { $in: ['sue', 'jakeb', 'jakob'] } })
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
cursor.sort({ other: -1 }).exec(function (err, docs) { cursor.sort({ other: -1 }).exec(function (err, docs) {
docs.length.should.equal(2) docs.length.should.equal(2)
return cb() return cb()
@ -592,7 +592,7 @@ describe('Cursor', function () {
}, },
function (cb) { function (cb) {
const cursor = new Cursor(d, {}) const cursor = new Cursor(d, {})
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
cursor.sort({ name: 1, age: -1 }).exec(function (err, docs) { cursor.sort({ name: 1, age: -1 }).exec(function (err, docs) {
docs.length.should.equal(5) docs.length.should.equal(5)
@ -606,7 +606,7 @@ describe('Cursor', function () {
}, },
function (cb) { function (cb) {
const cursor = new Cursor(d, {}) const cursor = new Cursor(d, {})
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
cursor.sort({ name: 1, age: 1 }).exec(function (err, docs) { cursor.sort({ name: 1, age: 1 }).exec(function (err, docs) {
docs.length.should.equal(5) docs.length.should.equal(5)
@ -620,7 +620,7 @@ describe('Cursor', function () {
}, },
function (cb) { function (cb) {
const cursor = new Cursor(d, {}) const cursor = new Cursor(d, {})
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
cursor.sort({ age: 1, name: 1 }).exec(function (err, docs) { cursor.sort({ age: 1, name: 1 }).exec(function (err, docs) {
docs.length.should.equal(5) docs.length.should.equal(5)
@ -634,7 +634,7 @@ describe('Cursor', function () {
}, },
function (cb) { function (cb) {
const cursor = new Cursor(d, {}) const cursor = new Cursor(d, {})
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
cursor.sort({ age: 1, name: -1 }).exec(function (err, docs) { cursor.sort({ age: 1, name: -1 }).exec(function (err, docs) {
docs.length.should.equal(5) docs.length.should.equal(5)
@ -677,7 +677,7 @@ describe('Cursor', function () {
d.insert(entity, function () { d.insert(entity, function () {
callback() callback()
}) })
}, // eslint-disable-next-line node/handle-callback-err }, // eslint-disable-next-line n/handle-callback-err
function (err) { function (err) {
return cb() return cb()
}) })
@ -685,7 +685,7 @@ describe('Cursor', function () {
}, },
function (cb) { function (cb) {
const cursor = new Cursor(d, {}) const cursor = new Cursor(d, {})
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
cursor.sort({ company: 1, cost: 1 }).exec(function (err, docs) { cursor.sort({ company: 1, cost: 1 }).exec(function (err, docs) {
docs.length.should.equal(60) docs.length.should.equal(60)
@ -709,19 +709,19 @@ describe('Cursor', function () {
beforeEach(function (done) { beforeEach(function (done) {
// We don't know the order in which docs wil be inserted but we ensure correctness by testing both sort orders // We don't know the order in which docs wil be inserted but we ensure correctness by testing both sort orders
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.insert({ age: 5, name: 'Jo', planet: 'B', toys: { bebe: true, ballon: 'much' } }, function (err, _doc0) { d.insert({ age: 5, name: 'Jo', planet: 'B', toys: { bebe: true, ballon: 'much' } }, function (err, _doc0) {
doc0 = _doc0 doc0 = _doc0
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.insert({ age: 57, name: 'Louis', planet: 'R', toys: { ballon: 'yeah', bebe: false } }, function (err, _doc1) { d.insert({ age: 57, name: 'Louis', planet: 'R', toys: { ballon: 'yeah', bebe: false } }, function (err, _doc1) {
doc1 = _doc1 doc1 = _doc1
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.insert({ age: 52, name: 'Grafitti', planet: 'C', toys: { bebe: 'kind of' } }, function (err, _doc2) { d.insert({ age: 52, name: 'Grafitti', planet: 'C', toys: { bebe: 'kind of' } }, function (err, _doc2) {
doc2 = _doc2 doc2 = _doc2
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.insert({ age: 23, name: 'LM', planet: 'S' }, function (err, _doc3) { d.insert({ age: 23, name: 'LM', planet: 'S' }, function (err, _doc3) {
doc3 = _doc3 doc3 = _doc3
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.insert({ age: 89, planet: 'Earth' }, function (err, _doc4) { d.insert({ age: 89, planet: 'Earth' }, function (err, _doc4) {
doc4 = _doc4 doc4 = _doc4
return done() return done()
@ -853,7 +853,7 @@ describe('Cursor', function () {
const cursor = new Cursor(d, {}) const cursor = new Cursor(d, {})
cursor.sort({ age: 1 }) // For easier finding cursor.sort({ age: 1 }) // For easier finding
cursor.projection({ name: 0, planet: 0, 'toys.bebe': 0, _id: 0 }) cursor.projection({ name: 0, planet: 0, 'toys.bebe': 0, _id: 0 })
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
cursor.exec(function (err, docs) { cursor.exec(function (err, docs) {
assert.deepStrictEqual(docs[0], { age: 5, toys: { ballon: 'much' } }) assert.deepStrictEqual(docs[0], { age: 5, toys: { ballon: 'much' } })
assert.deepStrictEqual(docs[1], { age: 23 }) assert.deepStrictEqual(docs[1], { age: 23 })
@ -869,7 +869,7 @@ describe('Cursor', function () {
const cursor = new Cursor(d, {}) const cursor = new Cursor(d, {})
cursor.sort({ age: 1 }) // For easier finding cursor.sort({ age: 1 }) // For easier finding
cursor.projection({ name: 1, 'toys.ballon': 1, _id: 0 }) cursor.projection({ name: 1, 'toys.ballon': 1, _id: 0 })
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
cursor.exec(function (err, docs) { cursor.exec(function (err, docs) {
assert.deepStrictEqual(docs[0], { name: 'Jo', toys: { ballon: 'much' } }) assert.deepStrictEqual(docs[0], { name: 'Jo', toys: { ballon: 'much' } })
assert.deepStrictEqual(docs[1], { name: 'LM' }) assert.deepStrictEqual(docs[1], { name: 'LM' })

@ -810,7 +810,7 @@ describe('Database async', function () {
await d.updateAsync({ $or: [{ a: 4 }, { a: 5 }] }, { await d.updateAsync({ $or: [{ a: 4 }, { a: 5 }] }, {
$set: { hello: 'world' }, $set: { hello: 'world' },
$inc: { bloup: 3 } $inc: { bloup: 3 }
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
}, { upsert: true }) }, { upsert: true })
const docs = await d.findAsync({ hello: 'world' }) const docs = await d.findAsync({ hello: 'world' })
assert.equal(docs.length, 1) assert.equal(docs.length, 1)
@ -824,7 +824,7 @@ describe('Database async', function () {
await d.updateAsync({ $or: [{ a: 4 }, { a: 5 }], cac: 'rrr' }, { await d.updateAsync({ $or: [{ a: 4 }, { a: 5 }], cac: 'rrr' }, {
$set: { hello: 'world' }, $set: { hello: 'world' },
$inc: { bloup: 3 } $inc: { bloup: 3 }
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
}, { upsert: true }) }, { upsert: true })
const docs = await d.findAsync({ hello: 'world' }) const docs = await d.findAsync({ hello: 'world' })
assert.equal(docs.length, 1) assert.equal(docs.length, 1)
@ -1400,9 +1400,9 @@ describe('Database async', function () {
assert.deepEqual(Object.keys(d.indexes), ['_id']) assert.deepEqual(Object.keys(d.indexes), ['_id'])
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
const newDoc1 = await d.insertAsync({ z: '12', yes: 'yes' }) const newDoc1 = await d.insertAsync({ z: '12', yes: 'yes' })
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
const newDoc2 = await d.insertAsync({ z: '14', nope: 'nope' }) const newDoc2 = await d.insertAsync({ z: '14', nope: 'nope' })
await d.removeAsync({ z: '2' }, {}) await d.removeAsync({ z: '2' }, {})
await d.updateAsync({ z: '1' }, { $set: { yes: 'yep' } }, {}) await d.updateAsync({ z: '1' }, { $set: { yes: 'yep' } }, {})

File diff suppressed because it is too large Load Diff

@ -20,7 +20,7 @@ function testThrowInCallback (d, done) {
process.removeAllListeners('uncaughtException') process.removeAllListeners('uncaughtException')
process.removeAllListeners('unhandledRejection') process.removeAllListeners('unhandledRejection')
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
process.on('uncaughtException', function (err) { process.on('uncaughtException', function (err) {
// Do nothing with the error which is only there to test we stay on track // Do nothing with the error which is only there to test we stay on track
}) })
@ -29,10 +29,10 @@ function testThrowInCallback (d, done) {
// Do nothing with the error which is only there to test we stay on track // Do nothing with the error which is only there to test we stay on track
}) })
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.find({}, function (err) { d.find({}, function (err) {
process.nextTick(function () { process.nextTick(function () {
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.insert({ bar: 1 }, function (err) { d.insert({ bar: 1 }, function (err) {
process.removeAllListeners('uncaughtException') process.removeAllListeners('uncaughtException')
process.removeAllListeners('unhandledRejection') process.removeAllListeners('unhandledRejection')
@ -78,24 +78,24 @@ function testRightOrder (d, done) {
process.removeAllListeners('uncaughtException') process.removeAllListeners('uncaughtException')
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
process.on('uncaughtException', function (err) { process.on('uncaughtException', function (err) {
// Do nothing with the error which is only there to test we stay on track // Do nothing with the error which is only there to test we stay on track
}) })
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.find({}, function (err, docs) { d.find({}, function (err, docs) {
docs.length.should.equal(0) docs.length.should.equal(0)
d.insert({ a: 1 }, function () { d.insert({ a: 1 }, function () {
d.update({ a: 1 }, { a: 2 }, {}, function () { d.update({ a: 1 }, { a: 2 }, {}, function () {
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.find({}, function (err, docs) { d.find({}, function (err, docs) {
docs[0].a.should.equal(2) docs[0].a.should.equal(2)
process.nextTick(function () { process.nextTick(function () {
d.update({ a: 2 }, { a: 3 }, {}, function () { d.update({ a: 2 }, { a: 3 }, {}, function () {
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.find({}, function (err, docs) { d.find({}, function (err, docs) {
docs[0].a.should.equal(3) docs[0].a.should.equal(3)
@ -125,7 +125,7 @@ const testEventLoopStarvation = function (d, done) {
let i = 0 let i = 0
while (i < times) { while (i < times) {
i++ i++
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.find({ bogus: 'search' }, function (err, docs) { d.find({ bogus: 'search' }, function (err, docs) {
}) })
} }
@ -136,7 +136,7 @@ const testEventLoopStarvation = function (d, done) {
function testExecutorWorksWithoutCallback (d, done) { function testExecutorWorksWithoutCallback (d, done) {
d.insert({ a: 1 }) d.insert({ a: 1 })
d.insert({ a: 2 }, false) d.insert({ a: 2 }, false)
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.find({}, function (err, docs) { d.find({}, function (err, docs) {
docs.length.should.equal(2) docs.length.should.equal(2)
done() done()

@ -668,7 +668,7 @@ describe('Persistence', function () {
beforeDeserialization: bd beforeDeserialization: bd
}) })
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.insert({ hello: 'world' }, function (err, doc) { d.insert({ hello: 'world' }, function (err, doc) {
const _id = doc._id const _id = doc._id
d.insert({ yo: 'ya' }, function () { d.insert({ yo: 'ya' }, function () {
@ -687,7 +687,7 @@ describe('Persistence', function () {
beforeDeserialization: bd beforeDeserialization: bd
}) })
d.loadDatabase(function () { d.loadDatabase(function () {
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.find({}, function (err, docs) { d.find({}, function (err, docs) {
docs.length.should.equal(1) docs.length.should.equal(1)
docs[0].hello.should.equal('earth') docs[0].hello.should.equal('earth')
@ -823,7 +823,7 @@ describe('Persistence', function () {
it('persistCachedDatabase should update the contents of the datafile and leave a clean state', function (done) { it('persistCachedDatabase should update the contents of the datafile and leave a clean state', function (done) {
d.insert({ hello: 'world' }, function () { d.insert({ hello: 'world' }, function () {
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.find({}, function (err, docs) { d.find({}, function (err, docs) {
docs.length.should.equal(1) docs.length.should.equal(1)
@ -850,7 +850,7 @@ describe('Persistence', function () {
it('After a persistCachedDatabase, there should be no temp or old filename', function (done) { it('After a persistCachedDatabase, there should be no temp or old filename', function (done) {
d.insert({ hello: 'world' }, function () { d.insert({ hello: 'world' }, function () {
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.find({}, function (err, docs) { d.find({}, function (err, docs) {
docs.length.should.equal(1) docs.length.should.equal(1)
@ -878,7 +878,7 @@ describe('Persistence', function () {
it('persistCachedDatabase should update the contents of the datafile and leave a clean state even if there is a temp datafile', function (done) { it('persistCachedDatabase should update the contents of the datafile and leave a clean state even if there is a temp datafile', function (done) {
d.insert({ hello: 'world' }, function () { d.insert({ hello: 'world' }, function () {
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
d.find({}, function (err, docs) { d.find({}, function (err, docs) {
docs.length.should.equal(1) docs.length.should.equal(1)
@ -1037,7 +1037,7 @@ describe('Persistence', function () {
fs.existsSync('workspace/lac.db~').should.equal(false) fs.existsSync('workspace/lac.db~').should.equal(false)
fs.readFileSync('workspace/lac.db', 'utf8').length.should.equal(datafileLength) fs.readFileSync('workspace/lac.db', 'utf8').length.should.equal(datafileLength)
// eslint-disable-next-line node/handle-callback-err // eslint-disable-next-line n/handle-callback-err
db.find({}, function (err, docs) { db.find({}, function (err, docs) {
docs.length.should.equal(N) docs.length.should.equal(N)
for (i = 0; i < N; i += 1) { for (i = 0; i < N; i += 1) {

@ -33,7 +33,7 @@ const wait = delay => new Promise(resolve => {
}) })
const exists = path => fs.access(path, fsConstants.FS_OK).then(() => true, () => false) const exists = path => fs.access(path, fsConstants.FS_OK).then(() => true, () => false)
// eslint-disable-next-line node/no-callback-literal // eslint-disable-next-line n/no-callback-literal
const existsCallback = (path, callback) => fs.access(path, fsConstants.FS_OK).then(() => callback(true), () => callback(false)) const existsCallback = (path, callback) => fs.access(path, fsConstants.FS_OK).then(() => callback(true), () => callback(false))
module.exports.whilst = whilst module.exports.whilst = whilst

@ -14,7 +14,7 @@ module.exports = (env, argv) => {
global: true global: true
}, },
optimization: { optimization: {
minimize: minimize minimize
}, },
resolve: { resolve: {
fallback: { fallback: {

Loading…
Cancel
Save