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
well adapted to non-US characters in particular accented letters. Native <code>localCompare</code> will most of the time be
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>
@ -501,7 +503,7 @@ preferable to instantiate a new one.</p>
**Params**
- 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>
- [.sparse] <code>boolean</code> <code> = false</code>
- [.expireAfterSeconds] <code>number</code>
@ -518,8 +520,8 @@ executor.</p>
**Params**
- 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
document.</p>
- .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. 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
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
@ -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>
- [.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>
- [.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>

@ -6,6 +6,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres
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
### Added
- 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
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`.
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`
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:
```javascript

@ -39,7 +39,7 @@ module.exports.getConfiguration = function (benchDb) {
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()
}
// eslint-disable-next-line node/handle-callback-err
// eslint-disable-next-line n/handle-callback-err
d.insert({ docNumber: order[i] }, function (err) {
executeAsap(function () {
runFrom(i + 1)
@ -122,7 +122,7 @@ module.exports.findDocs = function (d, n, profiler, 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) {
if (docs.length !== 1 || docs[0].docNumber !== order[i]) { return cb(new Error('One find didnt work')) }
executeAsap(function () {
@ -159,7 +159,7 @@ module.exports.findDocsWithIn = function (d, n, profiler, 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) {
if (docs.length !== arraySize) { return cb(new Error('One find didnt work')) }
executeAsap(function () {
@ -186,7 +186,7 @@ module.exports.findOneDocs = function (d, n, profiler, 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) {
if (!doc || doc.docNumber !== order[i]) { return cb(new Error('One find didnt work')) }
executeAsap(function () {
@ -250,7 +250,7 @@ module.exports.removeDocs = function (options, d, n, profiler, cb) {
d.remove({ docNumber: order[i] }, options, function (err, nr) {
if (err) { return cb(err) }
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
// So actually we're calculating the average time taken by one insert + one remove
executeAsap(function () {
@ -276,7 +276,7 @@ module.exports.loadDatabase = function (d, n, profiler, cb) {
return cb()
}
// eslint-disable-next-line node/handle-callback-err
// eslint-disable-next-line n/handle-callback-err
d.loadDatabase(function (err) {
executeAsap(function () {
runFrom(i + 1)

@ -25,7 +25,7 @@ waterfall([
apply(commonUtilities.updateDocs, { multi: false }, d, n, profiler),
// 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() }) },
apply(commonUtilities.insertDocs, d, n, profiler),
function (cb) { profiler.step('MULTI: TRUE'); return cb() },

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

@ -73,7 +73,7 @@ class Index {
* Options object given to the underlying BinarySearchTree.
* @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.

@ -221,7 +221,7 @@ class Persistence {
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)
resolve({ data, indexes: indexes })
resolve({ data, indexes })
})
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) => {
try {
const stream = writeFileStream(filename, { mode: mode })
const stream = writeFileStream(filename, { mode })
const readable = Readable.from(lines)
readable.on('data', (line) => {
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]'
/**
* 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 {*} keys
* @returns
* @param {object} object
* @param {string[]} keys
* @return {object}
*/
const pick = (object, keys) => {
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",
"email": "me@eliotakira.com",
"url": "https://eliotakira.com/"
},
{
"name": " Loïc Hermann",
"email": "loic.hermann@outlook.fr"
}
],
"description": "File-based embedded data store for node.js",
@ -41,40 +45,41 @@
"url": "git@github.com:seald/nedb.git"
},
"dependencies": {
"@seald-io/binary-search-tree": "^1.0.2",
"@seald-io/binary-search-tree": "^1.0.3",
"localforage": "^1.9.0",
"util": "^0.12.4"
},
"devDependencies": {
"@react-native-async-storage/async-storage": "^1.15.9",
"@types/jest": "^27.0.2",
"@react-native-async-storage/async-storage": "^1.17.11",
"@types/jest": "^27.5.2",
"browser-resolve": "^2.0.0",
"chai": "^4.3.4",
"chai": "^4.3.7",
"commander": "^7.2.0",
"events": "^3.3.0",
"jest": "^27.3.1",
"jsdoc-to-markdown": "^7.1.0",
"karma": "^6.3.2",
"jest": "^27.5.1",
"jsdoc-to-markdown": "^8.0.0",
"karma": "^6.4.1",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.1.0",
"karma-chrome-launcher": "^3.1.1",
"karma-junit-reporter": "^2.0.1",
"karma-mocha": "^2.0.1",
"karma-source-map-support": "^1.4.0",
"mocha": "^9.1.3",
"mocha-junit-reporter": "^2.0.0",
"mocha": "^10.2.0",
"mocha-junit-reporter": "^2.2.0",
"path-browserify": "^1.0.1",
"process": "^0.11.10",
"react-native": "^0.66.0",
"semver": "^7.3.5",
"source-map-loader": "^2.0.2",
"standard": "^16.0.3",
"terser-webpack-plugin": "^5.1.2",
"react": "^18.2.0",
"react-native": "^0.71.0",
"semver": "^7.3.8",
"source-map-loader": "^4.0.1",
"standard": "^17.0.0",
"terser-webpack-plugin": "^5.3.6",
"timers-browserify": "^2.0.12",
"ts-jest": "^27.0.7",
"ts-node": "^10.3.0",
"typescript": "^4.4.4",
"webpack": "^5.37.0",
"webpack-cli": "^4.7.0",
"ts-jest": "^27.1.5",
"ts-node": "^10.9.1",
"typescript": "^4.9.4",
"webpack": "^5.75.0",
"webpack-cli": "^5.0.1",
"xvfb-maybe": "^0.2.1"
},
"scripts": {

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

@ -277,7 +277,7 @@ describe('Cursor Async', function () {
await d.insertAsync({ name: 'henry', other: 4 })
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 })
assert.equal(docs.length, 4)
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: 'jako', age: 35, nid: 5 })
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 })
assert.equal(docs.length, 5)

@ -40,15 +40,15 @@ describe('Cursor', function () {
describe('Without sorting', function () {
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) {
// eslint-disable-next-line node/handle-callback-err
// eslint-disable-next-line n/handle-callback-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) {
// eslint-disable-next-line node/handle-callback-err
// eslint-disable-next-line n/handle-callback-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) {
return done()
})
@ -152,15 +152,15 @@ describe('Cursor', function () {
describe('Sorting of the results', function () {
beforeEach(function (done) {
// 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) {
// eslint-disable-next-line node/handle-callback-err
// eslint-disable-next-line n/handle-callback-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) {
// eslint-disable-next-line node/handle-callback-err
// eslint-disable-next-line n/handle-callback-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) {
return done()
})
@ -204,14 +204,14 @@ describe('Cursor', function () {
db.insert({ name: 'charlie' })
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) {
docs.map(x => x.name)[0].should.equal('zulu')
docs.map(x => x.name)[1].should.equal('alpha')
docs.map(x => x.name)[2].should.equal('charlie')
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) {
docs.map(x => x.name)[0].should.equal('alpha')
docs.map(x => x.name)[1].should.equal('charlie')
@ -416,7 +416,7 @@ describe('Cursor', function () {
},
function (cb) {
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) {
docs.length.should.equal(3)
docs[0].name.should.equal('jakeb')
@ -427,7 +427,7 @@ describe('Cursor', function () {
},
function (cb) {
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) {
docs.length.should.equal(3)
docs[0].name.should.equal('sue')
@ -449,13 +449,13 @@ describe('Cursor', function () {
d.remove({}, { multi: true }, function (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) {
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) {
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) {
doc3 = _doc3
return cb()
@ -466,7 +466,7 @@ describe('Cursor', function () {
},
function (cb) {
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) {
docs.length.should.equal(3)
docs[0]._id.should.equal(doc3._id)
@ -477,7 +477,7 @@ describe('Cursor', function () {
},
function (cb) {
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) {
docs.length.should.equal(3)
docs[0]._id.should.equal(doc2._id)
@ -508,7 +508,7 @@ describe('Cursor', function () {
},
function (cb) {
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) {
docs.length.should.equal(4)
docs[0].name.should.equal('sue')
@ -524,7 +524,7 @@ describe('Cursor', function () {
},
function (cb) {
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) {
docs.length.should.equal(2)
docs[0].name.should.equal('jakeb')
@ -554,7 +554,7 @@ describe('Cursor', function () {
},
function (cb) {
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) {
docs.length.should.equal(3)
return cb()
@ -562,7 +562,7 @@ describe('Cursor', function () {
},
function (cb) {
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) {
docs.length.should.equal(2)
return cb()
@ -592,7 +592,7 @@ describe('Cursor', function () {
},
function (cb) {
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) {
docs.length.should.equal(5)
@ -606,7 +606,7 @@ describe('Cursor', function () {
},
function (cb) {
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) {
docs.length.should.equal(5)
@ -620,7 +620,7 @@ describe('Cursor', function () {
},
function (cb) {
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) {
docs.length.should.equal(5)
@ -634,7 +634,7 @@ describe('Cursor', function () {
},
function (cb) {
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) {
docs.length.should.equal(5)
@ -677,7 +677,7 @@ describe('Cursor', function () {
d.insert(entity, function () {
callback()
})
}, // eslint-disable-next-line node/handle-callback-err
}, // eslint-disable-next-line n/handle-callback-err
function (err) {
return cb()
})
@ -685,7 +685,7 @@ describe('Cursor', function () {
},
function (cb) {
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) {
docs.length.should.equal(60)
@ -709,19 +709,19 @@ describe('Cursor', function () {
beforeEach(function (done) {
// 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) {
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) {
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) {
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) {
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) {
doc4 = _doc4
return done()
@ -853,7 +853,7 @@ describe('Cursor', function () {
const cursor = new Cursor(d, {})
cursor.sort({ age: 1 }) // For easier finding
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) {
assert.deepStrictEqual(docs[0], { age: 5, toys: { ballon: 'much' } })
assert.deepStrictEqual(docs[1], { age: 23 })
@ -869,7 +869,7 @@ describe('Cursor', function () {
const cursor = new Cursor(d, {})
cursor.sort({ age: 1 }) // For easier finding
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) {
assert.deepStrictEqual(docs[0], { name: 'Jo', toys: { ballon: 'much' } })
assert.deepStrictEqual(docs[1], { name: 'LM' })

@ -810,7 +810,7 @@ describe('Database async', function () {
await d.updateAsync({ $or: [{ a: 4 }, { a: 5 }] }, {
$set: { hello: 'world' },
$inc: { bloup: 3 }
// eslint-disable-next-line node/handle-callback-err
// eslint-disable-next-line n/handle-callback-err
}, { upsert: true })
const docs = await d.findAsync({ hello: 'world' })
assert.equal(docs.length, 1)
@ -824,7 +824,7 @@ describe('Database async', function () {
await d.updateAsync({ $or: [{ a: 4 }, { a: 5 }], cac: 'rrr' }, {
$set: { hello: 'world' },
$inc: { bloup: 3 }
// eslint-disable-next-line node/handle-callback-err
// eslint-disable-next-line n/handle-callback-err
}, { upsert: true })
const docs = await d.findAsync({ hello: 'world' })
assert.equal(docs.length, 1)
@ -1400,9 +1400,9 @@ describe('Database async', function () {
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' })
// 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' })
await d.removeAsync({ z: '2' }, {})
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('unhandledRejection')
// eslint-disable-next-line node/handle-callback-err
// eslint-disable-next-line n/handle-callback-err
process.on('uncaughtException', function (err) {
// 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
})
// eslint-disable-next-line node/handle-callback-err
// eslint-disable-next-line n/handle-callback-err
d.find({}, function (err) {
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) {
process.removeAllListeners('uncaughtException')
process.removeAllListeners('unhandledRejection')
@ -78,24 +78,24 @@ function testRightOrder (d, done) {
process.removeAllListeners('uncaughtException')
// eslint-disable-next-line node/handle-callback-err
// eslint-disable-next-line n/handle-callback-err
process.on('uncaughtException', function (err) {
// 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) {
docs.length.should.equal(0)
d.insert({ a: 1 }, 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) {
docs[0].a.should.equal(2)
process.nextTick(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) {
docs[0].a.should.equal(3)
@ -125,7 +125,7 @@ const testEventLoopStarvation = function (d, done) {
let i = 0
while (i < times) {
i++
// eslint-disable-next-line node/handle-callback-err
// eslint-disable-next-line n/handle-callback-err
d.find({ bogus: 'search' }, function (err, docs) {
})
}
@ -136,7 +136,7 @@ const testEventLoopStarvation = function (d, done) {
function testExecutorWorksWithoutCallback (d, done) {
d.insert({ a: 1 })
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) {
docs.length.should.equal(2)
done()

@ -668,7 +668,7 @@ describe('Persistence', function () {
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) {
const _id = doc._id
d.insert({ yo: 'ya' }, function () {
@ -687,7 +687,7 @@ describe('Persistence', function () {
beforeDeserialization: bd
})
d.loadDatabase(function () {
// eslint-disable-next-line node/handle-callback-err
// eslint-disable-next-line n/handle-callback-err
d.find({}, function (err, docs) {
docs.length.should.equal(1)
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) {
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) {
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) {
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) {
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) {
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) {
docs.length.should.equal(1)
@ -1037,7 +1037,7 @@ describe('Persistence', function () {
fs.existsSync('workspace/lac.db~').should.equal(false)
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) {
docs.length.should.equal(N)
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)
// 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))
module.exports.whilst = whilst

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

Loading…
Cancel
Save