nedb-promises
Advanced tools
Comparing version 6.1.0 to 6.2.0
@@ -13,12 +13,46 @@ module.exports = { | ||
rules: { | ||
'indent': [ 'error', 4 ], | ||
'linebreak-style': [ 'error', 'unix' ], | ||
'quotes': [ 'error', 'single' ], | ||
'semi': [ 'error', 'always' ], | ||
'comma-dangle': [ 'error', 'always-multiline' ], | ||
'quote-props': [ 'error', 'consistent-as-needed' ], | ||
'no-multiple-empty-lines': [ 'error' ], | ||
'space-before-function-paren': [ 'error', { anonymous: 'never', named: 'never', asyncArrow: 'always' } ], | ||
'default-case-last': [ 'error' ], | ||
'array-bracket-spacing': ['error', 'never'], | ||
'array-element-newline': ['error', 'consistent'], | ||
'arrow-spacing': ['error', { before: true, after: true }], | ||
'arrow-parens': ['error', 'always'], | ||
'block-spacing': ['error', 'always'], | ||
'brace-style': ['error', '1tbs', { allowSingleLine: true }], | ||
'comma-dangle': ['error', 'always-multiline'], | ||
'comma-spacing': ['error', { before: false, after: true }], | ||
'comma-style': ['error', 'last'], | ||
'computed-property-spacing': ['error', 'never'], | ||
'default-case-last': ['error'], | ||
'dot-location': ['error', 'property'], | ||
'func-call-spacing': ['error', 'never'], | ||
'function-call-argument-newline': ['error', 'consistent'], | ||
'eol-last': ['error', 'always'], | ||
'indent': ['error', 4], | ||
'key-spacing': ['error', { mode: 'strict' }], | ||
'keyword-spacing': ['error', { before: true, after: true }], | ||
'linebreak-style': ['error', 'unix'], | ||
'no-multi-spaces': 'error', | ||
'no-multiple-empty-lines': ['error', { max: 1, maxBOF: 0, maxEOF: 1 }], | ||
'no-nested-ternary': 'error', | ||
'no-new-object': 'error', | ||
'no-new-wrappers': 'error', | ||
'no-octal-escape': 'error', | ||
'no-return-await': 'error', | ||
'no-tabs': 'error', | ||
'no-throw-literal': 'error', | ||
'no-use-before-define': ['error', { functions: false, classes: true, variables: true }], | ||
'no-whitespace-before-property': 'error', | ||
'object-curly-spacing': ['error', 'always'], | ||
'operator-linebreak': ['error', 'before'], | ||
'padded-blocks': ['error', 'never'], | ||
'prefer-promise-reject-errors': 'error', | ||
'prefer-rest-params': 'error', | ||
'prefer-spread': 'error', | ||
'prefer-template': 'error', | ||
'quote-props': ['error', 'consistent-as-needed'], | ||
'quotes': ['error', 'single'], | ||
'rest-spread-spacing': ['error', 'never'], | ||
'semi': ['error', 'always'], | ||
'space-before-function-paren': ['error', { anonymous: 'never', named: 'never', asyncArrow: 'always' }], | ||
'template-curly-spacing': ['error', 'never'], | ||
}, | ||
}; |
@@ -7,2 +7,18 @@ # Changelog | ||
## 6.2.0 | ||
### Added | ||
- `Datastore.removeOne` and `Datastore.removeMany` aliases. | ||
- MongoDB compatibility methods (`Datastore.insertOne`, `Datastore.insertMany`, `Datastore.updateOne`, `Datastore.updateMany`, `Datastore.deleteOne`, `Datastore.deleteMany`). | ||
## 6.1.0 | ||
### Updated | ||
- Code to use the async API instead of callbacks. | ||
### Fixed | ||
- Vulnerable dependencies. | ||
## 6.0.3 | ||
### Fixed | ||
- Vulnerable dependencies. | ||
## 6.0.2 | ||
@@ -9,0 +25,0 @@ ### Fixed |
194
docs.md
@@ -157,4 +157,12 @@ ## Classes | ||
* [.insert(docs)](#Datastore+insert) ⇒ <code>Promise.<(Object\|Array.<Object>)></code> | ||
* [.insertOne(doc)](#Datastore+insertOne) ⇒ <code>Promise.<Object></code> | ||
* [.insertMany(docs)](#Datastore+insertMany) ⇒ <code>Promise.<Array.<Object>></code> | ||
* [.update(query, update, [options])](#Datastore+update) ⇒ <code>Promise.<(number\|Object\|Array.<Object>)></code> | ||
* [.updateOne(query, update, [options])](#Datastore+updateOne) ⇒ <code>Promise.<(number\|Object)></code> | ||
* [.updateMany(query, update, [options])](#Datastore+updateMany) ⇒ <code>Promise.<(number\|Array.<Object>)></code> | ||
* [.remove([query], [options])](#Datastore+remove) ⇒ <code>Promise.<number></code> | ||
* [.removeOne([query], [options])](#Datastore+removeOne) ⇒ <code>Promise.<number></code> | ||
* [.removeMany([query], [options])](#Datastore+removeMany) ⇒ <code>Promise.<number></code> | ||
* [.deleteOne([query], [options])](#Datastore+deleteOne) ⇒ <code>Promise.<number></code> | ||
* [.deleteMany([query], [options])](#Datastore+deleteMany) ⇒ <code>Promise.<number></code> | ||
* [.count([query])](#Datastore+count) ⇒ [<code>Cursor</code>](#Cursor) | ||
@@ -246,3 +254,3 @@ * [.ensureIndex(options)](#Datastore+ensureIndex) ⇒ <code>Promise.<undefined></code> | ||
### datastore.find([query], [projection]) ⇒ [<code>Cursor</code>](#Cursor) | ||
Find documents that match a query. | ||
Find documents that match the specified `query`. | ||
@@ -285,3 +293,3 @@ It's basically the same as the original: | ||
### datastore.findOne([query], [projection]) ⇒ [<code>Cursor</code>](#Cursor) | ||
Find a document that matches a query. | ||
Find a document that matches the specified `query`. | ||
@@ -336,6 +344,48 @@ It's basically the same as the original: | ||
<a name="Datastore+insertOne"></a> | ||
### datastore.insertOne(doc) ⇒ <code>Promise.<Object></code> | ||
Insert a single document. | ||
This is just an alias for `insert` with object destructuring | ||
to ensure a single document. | ||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>Param</th><th>Type</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>doc</td><td><code>Object</code></td> | ||
</tr> </tbody> | ||
</table> | ||
<a name="Datastore+insertMany"></a> | ||
### datastore.insertMany(docs) ⇒ <code>Promise.<Array.<Object>></code> | ||
Insert multiple documents. | ||
This is just an alias for `insert` with array destructuring | ||
to ensure multiple documents. | ||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>Param</th><th>Type</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>docs</td><td><code>Array.<Object></code></td> | ||
</tr> </tbody> | ||
</table> | ||
<a name="Datastore+update"></a> | ||
### datastore.update(query, update, [options]) ⇒ <code>Promise.<(number\|Object\|Array.<Object>)></code> | ||
Update documents that match a query. | ||
Update documents that match the specified `query`. | ||
@@ -367,6 +417,54 @@ It's basically the same as the original: | ||
<a name="Datastore+updateOne"></a> | ||
### datastore.updateOne(query, update, [options]) ⇒ <code>Promise.<(number\|Object)></code> | ||
Update a single document that matches the specified `query`. | ||
This is just an alias for `update` with `options.multi` set to `false`. | ||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>Param</th><th>Type</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>query</td><td><code>Object</code></td> | ||
</tr><tr> | ||
<td>update</td><td><code>Object</code></td> | ||
</tr><tr> | ||
<td>[options]</td><td><code>Object</code></td> | ||
</tr> </tbody> | ||
</table> | ||
<a name="Datastore+updateMany"></a> | ||
### datastore.updateMany(query, update, [options]) ⇒ <code>Promise.<(number\|Array.<Object>)></code> | ||
Update multiple documents that match the specified `query`. | ||
This is just an alias for `update` with `options.multi` set to `true`. | ||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>Param</th><th>Type</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>query</td><td><code>Object</code></td> | ||
</tr><tr> | ||
<td>update</td><td><code>Object</code></td> | ||
</tr><tr> | ||
<td>[options]</td><td><code>Object</code></td> | ||
</tr> </tbody> | ||
</table> | ||
<a name="Datastore+remove"></a> | ||
### datastore.remove([query], [options]) ⇒ <code>Promise.<number></code> | ||
Remove documents that match a query. | ||
Remove documents that match the specified `query`. | ||
@@ -391,2 +489,90 @@ It's basically the same as the original: | ||
<a name="Datastore+removeOne"></a> | ||
### datastore.removeOne([query], [options]) ⇒ <code>Promise.<number></code> | ||
Remove the first document that matches the specified `query`. | ||
This is just an alias for `remove` with `options.multi` set to `false`. | ||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>Param</th><th>Type</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>[query]</td><td><code>Object</code></td> | ||
</tr><tr> | ||
<td>[options]</td><td><code>Object</code></td> | ||
</tr> </tbody> | ||
</table> | ||
<a name="Datastore+removeMany"></a> | ||
### datastore.removeMany([query], [options]) ⇒ <code>Promise.<number></code> | ||
Remove all documents that match the specified `query`. | ||
This is just an alias for `remove` with `options.multi` set to `true`. | ||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>Param</th><th>Type</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>[query]</td><td><code>Object</code></td> | ||
</tr><tr> | ||
<td>[options]</td><td><code>Object</code></td> | ||
</tr> </tbody> | ||
</table> | ||
<a name="Datastore+deleteOne"></a> | ||
### datastore.deleteOne([query], [options]) ⇒ <code>Promise.<number></code> | ||
Remove the first document that matches the specified `query`. | ||
This is just an alias for `removeOne`. | ||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>Param</th><th>Type</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>[query]</td><td><code>Object</code></td> | ||
</tr><tr> | ||
<td>[options]</td><td><code>Object</code></td> | ||
</tr> </tbody> | ||
</table> | ||
<a name="Datastore+deleteMany"></a> | ||
### datastore.deleteMany([query], [options]) ⇒ <code>Promise.<number></code> | ||
Remove all documents that match the specified `query`. | ||
This is just an alias for `removeMany`. | ||
**Kind**: instance method of [<code>Datastore</code>](#Datastore) | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>Param</th><th>Type</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>[query]</td><td><code>Object</code></td> | ||
</tr><tr> | ||
<td>[options]</td><td><code>Object</code></td> | ||
</tr> </tbody> | ||
</table> | ||
<a name="Datastore+count"></a> | ||
@@ -393,0 +579,0 @@ |
{ | ||
"name": "nedb-promises", | ||
"version": "6.1.0", | ||
"version": "6.2.0", | ||
"description": "A dead-simple promise wrapper for nedb.", | ||
@@ -29,9 +29,9 @@ "main": "index.js", | ||
"dependencies": { | ||
"@seald-io/nedb": "^3.0.0" | ||
"@seald-io/nedb": "^3.1.0" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^8.6.0", | ||
"jest": "^28.1.1", | ||
"jest": "^29.0.3", | ||
"jsdoc-to-markdown": "^7.1.0" | ||
} | ||
} |
@@ -112,3 +112,3 @@ const OriginalCursor = require('@seald-io/nedb/lib/cursor'); | ||
* | ||
* @return {Promise.<Object[]>} | ||
* @return {Promise<Object[]>} | ||
*/ | ||
@@ -122,3 +122,3 @@ async exec() { | ||
} catch (error) { | ||
this.__datastore.broadcastError(this.__op, result, ...this.__args); | ||
this.__datastore.broadcastError(this.__op, error, ...this.__args); | ||
throw error; | ||
@@ -125,0 +125,0 @@ } |
@@ -83,3 +83,3 @@ const EventEmitter = require('events'); | ||
* @param {string|Object} [pathOrOptions] | ||
* @return {Proxy.<static>} | ||
* @return {Proxy<static>} | ||
*/ | ||
@@ -159,3 +159,3 @@ static create(pathOrOptions) { | ||
* | ||
* @return {Promise.<undefined>} | ||
* @return {Promise<undefined>} | ||
*/ | ||
@@ -173,3 +173,3 @@ load() { | ||
/** | ||
* Find documents that match a query. | ||
* Find documents that match the specified `query`. | ||
* | ||
@@ -204,3 +204,3 @@ * It's basically the same as the original: | ||
/** | ||
* Find a document that matches a query. | ||
* Find a document that matches the specified `query`. | ||
* | ||
@@ -236,3 +236,3 @@ * It's basically the same as the original: | ||
* @param {Object|Object[]} docs | ||
* @return {Promise.<Object|Object[]>} | ||
* @return {Promise<Object|Object[]>} | ||
*/ | ||
@@ -252,4 +252,30 @@ async insert(docs) { | ||
/** | ||
* Update documents that match a query. | ||
* Insert a single document. | ||
* | ||
* This is just an alias for `insert` with object destructuring | ||
* to ensure a single document. | ||
* | ||
* @param {Object} doc | ||
* @return {Promise<Object>} | ||
*/ | ||
insertOne({ ...doc }) { | ||
return this.insert(doc); | ||
} | ||
/** | ||
* Insert multiple documents. | ||
* | ||
* This is just an alias for `insert` with array destructuring | ||
* to ensure multiple documents. | ||
* | ||
* @param {Object[]} docs | ||
* @return {Promise<Object[]>} | ||
*/ | ||
insertMany([...docs]) { | ||
return this.insert(docs); | ||
} | ||
/** | ||
* Update documents that match the specified `query`. | ||
* | ||
* It's basically the same as the original: | ||
@@ -266,3 +292,3 @@ * https://github.com/louischatriot/nedb#updating-documents | ||
* @param {Object} [options] | ||
* @return {Promise.<number|Object|Object[]>} | ||
* @return {Promise<number|Object|Object[]>} | ||
*/ | ||
@@ -283,4 +309,34 @@ async update(query, update, options = {}) { | ||
/** | ||
* Remove documents that match a query. | ||
* Update a single document that matches the specified `query`. | ||
* | ||
* This is just an alias for `update` with `options.multi` set to `false`. | ||
* | ||
* @param {Object} query | ||
* @param {Object} update | ||
* @param {Object} [options] | ||
* | ||
* @return {Promise<number|Object>} | ||
*/ | ||
updateOne(query, update, options = {}) { | ||
return this.update(query, update, { ...options, multi: false }); | ||
} | ||
/** | ||
* Update multiple documents that match the specified `query`. | ||
* | ||
* This is just an alias for `update` with `options.multi` set to `true`. | ||
* | ||
* @param {Object} query | ||
* @param {Object} update | ||
* @param {Object} [options] | ||
* | ||
* @return {Promise<number|Object[]>} | ||
*/ | ||
updateMany(query, update, options = {}) { | ||
return this.update(query, update, { ...options, multi: true }); | ||
} | ||
/** | ||
* Remove documents that match the specified `query`. | ||
* | ||
* It's basically the same as the original: | ||
@@ -291,3 +347,3 @@ * https://github.com/louischatriot/nedb#removing-documents | ||
* @param {Object} [options] | ||
* @return {Promise.<number>} | ||
* @return {Promise<number>} | ||
*/ | ||
@@ -307,2 +363,58 @@ async remove(query = {}, options = {}) { | ||
/** | ||
* Remove the first document that matches the specified `query`. | ||
* | ||
* This is just an alias for `remove` with `options.multi` set to `false`. | ||
* | ||
* @param {Object} [query] | ||
* @param {Object} [options] | ||
* | ||
* @return {Promise<number>} | ||
*/ | ||
removeOne(query, options = {}) { | ||
return this.remove(query, { ...options, multi: false }); | ||
} | ||
/** | ||
* Remove all documents that match the specified `query`. | ||
* | ||
* This is just an alias for `remove` with `options.multi` set to `true`. | ||
* | ||
* @param {Object} [query] | ||
* @param {Object} [options] | ||
* | ||
* @return {Promise<number>} | ||
*/ | ||
removeMany(query, options = {}) { | ||
return this.remove(query, { ...options, multi: true }); | ||
} | ||
/** | ||
* Remove the first document that matches the specified `query`. | ||
* | ||
* This is just an alias for `removeOne`. | ||
* | ||
* @param {Object} [query] | ||
* @param {Object} [options] | ||
* | ||
* @return {Promise<number>} | ||
*/ | ||
deleteOne(query, options) { | ||
return this.removeOne(query, options); | ||
} | ||
/** | ||
* Remove all documents that match the specified `query`. | ||
* | ||
* This is just an alias for `removeMany`. | ||
* | ||
* @param {Object} [query] | ||
* @param {Object} [options] | ||
* | ||
* @return {Promise<number>} | ||
*/ | ||
deleteMany(query, options) { | ||
return this.removeMany(query, options); | ||
} | ||
/** | ||
* Count documents that match a query. | ||
@@ -333,3 +445,3 @@ * | ||
* @param {Object} options | ||
* @return {Promise.<undefined>} | ||
* @return {Promise<undefined>} | ||
*/ | ||
@@ -342,3 +454,3 @@ async ensureIndex(options) { | ||
} catch (error) { | ||
this.broadcastError('ensureIndex', error, field); | ||
this.broadcastError('ensureIndex', error, options); | ||
throw error; | ||
@@ -352,3 +464,3 @@ } | ||
* @param {string} field | ||
* @return {Promise.<undefined>} | ||
* @return {Promise<undefined>} | ||
*/ | ||
@@ -355,0 +467,0 @@ async removeIndex(field) { |
@@ -11,4 +11,4 @@ const Datastore = require('../src/Datastore'); | ||
const datastore = Datastore.create(); | ||
beforeEach(async () => await datastore.insert(docs)); | ||
afterEach(async () => await datastore.remove({}, { multi: true })); | ||
beforeEach(() => datastore.insert(docs)); | ||
afterEach(() => datastore.remove({}, { multi: true })); | ||
@@ -15,0 +15,0 @@ describe('single', () => { |
@@ -11,4 +11,4 @@ const Datastore = require('../src/Datastore'); | ||
const datastore = Datastore.create(); | ||
beforeEach(async () => await datastore.insert(docs)); | ||
afterEach(async () => await datastore.remove({}, { multi: true })); | ||
beforeEach(() => datastore.insert(docs)); | ||
afterEach(() => datastore.remove({}, { multi: true })); | ||
@@ -15,0 +15,0 @@ describe('single', () => { |
@@ -11,4 +11,4 @@ const Datastore = require('../src/Datastore'); | ||
const datastore = Datastore.create(); | ||
beforeEach(async () => await datastore.insert(docs)); | ||
afterEach(async () => await datastore.remove({}, { multi: true })); | ||
beforeEach(() => datastore.insert(docs)); | ||
afterEach(() => datastore.remove({}, { multi: true })); | ||
@@ -15,0 +15,0 @@ describe('count', () => { |
@@ -6,3 +6,3 @@ const Cursor = require('../src/Cursor'); | ||
describe('testing datastore proxy', () => { | ||
let datastore = Datastore.create('test.db'); | ||
const datastore = Datastore.create('test.db'); | ||
@@ -9,0 +9,0 @@ it('should not affect promise returns', () => { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
76466
19
1404
Updated@seald-io/nedb@^3.1.0