Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ampersand-collection-pouchdb-mixin

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ampersand-collection-pouchdb-mixin

A mixin for extending ampersand-collection with pouchdb persistance.

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 06 Oct 2014

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc