0.0.6 • Published 11 years ago

mongoose-watch v0.0.6

Weekly downloads
3
License
-
Repository
github
Last release
11 years ago

Mongoose Watch

This plugin has the capacity to generate queries in a certain time. This is to avoid using the "cappde" mongo while having certain documents, according as they changed, all based on dates.

So you will have control of a "real-time", but is the closest thing you can do.

Note: Do not use with .stream()

Install

You need

  • Nodejs
  • Npm
npm install mongosee-watch

Use

In your model

var mongoseeWatch = require('mongosee-watch');
var Player = new Schema({ ... });
Player.plugin( mongoseeWatch( "inLast" ) );

We build a query in mongoose, and give one or two parameters a watch.

var Query =  Player.find().where()...;
var watchPlayers = Query.watch( 'inLast' );
var player = 0;

watchPlayers.start(function (err, doc){
	if(err) return console.log(err);
	players = docs.length + players;
	console.log(players);
	if(players === 10 ) watchPlayers.stop();
});

Can modify parameters such as

  • the time the function returns.
  • Date query

Also you can build asynchronously

var Query = Player.find().where()...;
var player = 0;

Query.watch( 'inLast', function (start, stop){
	console.log("Start watch! ");
	start(function(err, doc){
		if(err) return console.log(err);
		players = docs.length + players;
		console.log(players);
		if(players === 10 ) stop();
	});
});
0.0.6

11 years ago

0.0.5

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago