Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including pouchdb-repository with all npm packages installed. Try it out:

var pouchdbRepository = require("pouchdb-repository")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

pouchdb-repository v0.6.1

Typescript repository for PouchDB.


Typescript repository for PouchDB. This library includes type definitions for PouchDB including strong type repository class.


npm install pouchdb-repository --save

Getting started

This library is designed to use with Typescript. For example, you have a model called Foo.

interface Foo {
    _id: string;
    name: string;

You can create FooRepository by overriding Repository

class FooRepository extends Repository<Foo> {
  constructor() {

let repo = new FooRepository();


Insert or update (Upsert)

You can insert of update by save method.{ _id: 'foo1', name: 'bar' });

If id is found in database, record will be updated, otherwise it will be inserted.

Get one

You can get item by passing the id.

let foo = await repo.get('foo1');

Type you get from this repo will always be Foo.



An object will be removed from db.

Save all

repo.saveAll([foo1, foo2]);

All objects will perform upsert operation.

Remove all

repo.removeAll([foo1, foo2]);

All specified objects will be removed from db.


Query options is from pouchdb-find. This library also includes typing definition.

let results = await repo.query({
  selector: { name: 'Mario' }
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free