mongodb-in-memory

1.3.1 • Public • Published

mongodb-in-memory

MongoDB compatible in-memory database for unit testing using TingoDB.

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

import { createDb } from 'mongodb-in-memory'
 
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'}})
}

/mongodb-in-memory/

    Package Sidebar

    Install

    npm i mongodb-in-memory

    Weekly Downloads

    5

    Version

    1.3.1

    License

    none

    Unpacked Size

    8 kB

    Total Files

    7

    Last publish

    Collaborators

    • sanjo