A Mongoose Plugin which emits events to connected socket.io clients
This plugin emits socket.io events on mongoose hooks. All events are sent on the post hook.
npm install mongoose-socket.io-events --save
const mongoose = require('mongoose');
const events = require('mongoose-socket.io-events');
var schema = mongoose.Schema({
name: String,
...
});
schema.use(events, {
port: 8080
});
mongoose:save
{
id: '' //Document ID
}
Option | Type | Default Value | Description |
---|---|---|---|
attach | HTTP Server | undefined |
A HTTP Server to attach to |
events | Object | {save: true, init: true, remove: true, validate: false} |
Configures the events to broadcast on |
namespace | String | / |
The Namespace to use |
port | Number | 80 |
The Port the socket.io Server should run on |
prefix | String | mongoose |
A Prefix value for all events |
room | String|Boolean | _id |
Either a document path which defines the Room the events shall be broadcasted to or false to broadcast to all sockets |
server | Socket.IO Server | undefined |
The Socket.io server instance to use |