npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mongoose-tail

v0.0.1

Published

Node.js module for mongoose-tail

Downloads

5

Readme

mongoose-tail

Node.js library for mongoose, like tail for mongoose. It allows to poll documents (with pre-defined conditions) at regular intervals (uses cron-module) and emit events when conditions are met.

News: 2013-06-14

  • individual/compined change-event
  • update documentation

Features:

-User defined find conditions, selections, limit

  • Trigging modes:

  • event when there is new document(s)

  • event if timestamp is older than it should be ( ~"heartbeat is too old" )

  • Trigging types:

  • count

  • documents (mongoose find results)

Options:

{
    mongoose:   Object        Mongoose instance
    modelname:  String        Registered model name,
    cron:       int|String    intervall in seconds/cron pattern for query intervall (optional, default: 10s interval)
    start:      Boolean       if query should start immediately (optional, default: false)
    
    individual: Boolean       individual change-events or compined event
    count:      Boolean       result emit only count event instead of data (optional, default: false)

    timefield:  String        Date-object field in mongoose model   (optional, default: 'timestamp')
    timeOffset: Int           timeOffset in seconds                 (optional, default: 0 )
    
    conditions: String|Object model find parameters (optional, default: {}), 
    limit:      Object        model limit parameters (optional, default: null),
    sort:       Object        model sort parameters (optional, default: {timestamp: -1} )
    select:     String        model select parameters (optional, default: null)
    
    olderThan:  Boolean       if true, find documents with field $lt -operator otherwise $gt (optional, default: false)
}

Usage

var mongooseTail = require('mongoose-tail');
var tail = new mongooseTail.Tail(  
  { /* options*/
    timefield: 'timestamp', 
    modelname: 'test', 
    start: true, 
    timeOffset: 10,
    olderThan: true,
    select: 'str',
    limit: 10,
    count: false,
  });

tail.on('tick', function(conditions){
  //console.log('tick');
});
tail.on('count', function(error){
  console.log('error');
});
tail.on('error', function(error){
  console.log('error');
});
tail.on('data', function(data){
  console.log('New data: '+JSON.stringify(data));
});

License

MIT - see LICENSE - file.