# mongoose-poll

> plugin to polling mongoose

Latest version **0.0.3** (published 2013-04-04) · BSD license · 0 weekly downloads

## Install

```sh
npm install mongoose-poll
pnpm add mongoose-poll
yarn add mongoose-poll
bun add mongoose-poll
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2013-04-04 |
| First published | 2012-11-22 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| Author | Ryota Suzuki |
| Maintainers | nunukim |

## Links

- npm: https://www.npmjs.com/package/mongoose-poll
- npm.io page: https://npm.io/package/mongoose-poll

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) *
- [coffee-script](https://npm.io/package/coffee-script.md) *

## Recent versions

- 0.0.3 (latest) — 2013-04-04
- 0.0.2 — 2013-04-04
- 0.0.1 — 2013-04-02
- 0.0.0 — 2012-11-22

## README

# mongoose-poll

[Mongoose]( http://mongoosejs.com/ "リンクのタイトル") plugin to polling models

# Usage
    var poll = require('mongoose-poll');

    var schema = new mongoose.Schema({
      state: {
        type: String,
        enum: ['init', 'running']
      },
      scope: String,
      at: Date,
    });
    schema.plugin(poll, {
      path: 'state',
      sort: {at: -1},
      interval: 100,
      query: function(){return {at: {'$lte': new Date}, scope: 'scope1'};}
    });

    var Model = mongoose.model('test_model', schema);

    Model.poll('init', 'running', function(doc){
      /* do something*/
      console.log("### doc found: ", doc);
    });

    var doc = new Model( {
      state: 'init',
      scope: 'scope1',
      at: new Date(Date.now() + 5000)
    });
    doc.save()

---
_Source: https://npm.io/package/mongoose-poll · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
