Socket
Socket
Sign inDemoInstall

ampersand-collection-pouchdb-mixin

Package Overview
Dependencies
170
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ampersand-collection-pouchdb-mixin

A mixin for extending ampersand-collection with pouchdb persistance.


Version published
Maintainers
1
Install size
24.6 MB
Created

Readme

Source

ampersand-collection-pouchdb-mixin

install

npm install ampersand-collection-pouchdb-mixin

example


var _ = require('underscore');

var AmpersandModel = require('ampersand-model');
var AmpersandPouchModelMixin = require('ampersand-model-pouchdb-mixin');

var AmpersandCollection = require('ampersand-collection');
var AmpersandUnderscoreMixin = require('ampersand-collection-underscore-mixin');
var AmpersandCollectionRestMixin = require('ampersand-collection-rest-mixin');
var AmpersandPouchCollectionMixin = require('ampersand-collection-pouchdb-mixin');

var Model = AmpersandModel.extend(AmpersandPouchModelMixin, {
  pouch: {
    database: 'mydb'
  },
  props: {
    firstName: 'string',
    lastName: 'string'
  }
});

module.exports = AmpersandCollection.extend(
  AmpersandPouchCollectionMixin,
  AmpersandCollectionRestMixin,
  AmpersandUnderscoreMixin, {
    mainIndex: '_id',
    model: Model,
    pouch: {
      database: 'mydb',
      fetch: 'query',
      options: {
        query: {
          include_docs: true,
          fun: {
            map: function(doc) {
              if (doc) {
                emit(doc, null);
              }
            }
          },
          limit: 10
        },
        changes: {
          include_docs: true,
          filter: function(doc) {
            return doc;
          }
        }
      }
    },
    parse: function(result) {
      // only return actual docs
      return _.pluck(result.rows, 'doc');
    }
});

Keywords

FAQs

Last updated on 06 Oct 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc