mongodb-in-memory
Advanced tools
Comparing version 1.1.0 to 1.2.0
14
index.js
@@ -8,2 +8,6 @@ 'use strict'; | ||
var _assign = require('babel-runtime/core-js/object/assign'); | ||
var _assign2 = _interopRequireDefault(_assign); | ||
var _regenerator = require('babel-runtime/regenerator'); | ||
@@ -104,3 +108,11 @@ | ||
_tcoll2.default.prototype.updateOne = _tcoll2.default.prototype.update; | ||
_tcoll2.default.prototype.updateMany = _tcoll2.default.prototype.update;['nextObject', 'count', 'close', 'toArray'].forEach(function (methodName) { | ||
_tcoll2.default.prototype.updateMany = _tcoll2.default.prototype.update; | ||
_tcoll2.default.prototype.deleteOne = function (filter) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
options = (0, _assign2.default)({}, options, { single: true }); | ||
return _tcoll2.default.prototype.remove.call(this, filter, options); | ||
}; | ||
_tcoll2.default.prototype.deleteMany = _tcoll2.default.prototype.remove;['nextObject', 'count', 'close', 'toArray'].forEach(function (methodName) { | ||
_tcursor2.default.prototype[methodName] = _bluebird2.default.promisify(_tcursor2.default.prototype[methodName]); | ||
@@ -107,0 +119,0 @@ }); |
{ | ||
"name": "mongodb-in-memory", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "build": "babel -d . src/" |
@@ -5,2 +5,6 @@ # mongodb-in-memory | ||
This package is a thin wrapper around TingoDB. | ||
It converts TingoDb's API to Promise API | ||
and adds methods that you can find in the MongoDB Node.js package to the collection. | ||
## Usage | ||
@@ -12,2 +16,10 @@ | ||
const db = createDb() | ||
demo() | ||
async function demo () { | ||
const users = db.collection('users') | ||
const userId = (await users.insertOne({name: 'Jonas'})).insertedId | ||
const user = await users.findOne({_id: userId}) | ||
await users.updateOne({_id: userId}, {$set: {name: 'Tom'}}) | ||
} | ||
``` |
@@ -50,2 +50,8 @@ import tingodb from 'tingodb' | ||
Collection.prototype.deleteOne = function (filter, options = {}) { | ||
options = Object.assign({}, options, {single: true}) | ||
return Collection.prototype.remove.call(this, filter, options) | ||
} | ||
Collection.prototype.deleteMany = Collection.prototype.remove | ||
;[ | ||
@@ -52,0 +58,0 @@ 'nextObject', |
7870
152
24
6