regina v0.0.9
Regina : Real-time database using MongoDB and Socket.IO
- Regina allows to run MongoDB - 'insert',- 'find',- 'update',- 'delete',- 'count', and- 'aggregate'methods directly from the client side (such as firebase).
- Regina can track - tagsbased events and send back messages containing the- resultof the requests and their- contextto client's sockets subscribed to these tags.
- Regina uses Socket.IO for client-server communication and event tracking. 
How it works

Installation
- npm install -g regina
Usage
Server side
Run with the default settings (
db='localhost:27017/reginadb'andport=3009) : 1.mongod2.regina3. open your browser atlocalhost:3009and check that you are on the regina home page.Run with custom settings : 1.
mongod --port 50002.regina 'localhost:5000/mydb' 60003. open your browser atlocalhost:6000check that you are on the regina home page.
Client side
Import socket.io client and follow these instructions : 1. create a socket instance with the regina server address :
var socket = io('http://localhost:3009/');
- send requests to the regina server using one of these type of requests :
socket.emit('insert', collection, docs, options, meta, ack);
socket.emit('find', collection, query, options, meta, ack);
socket.emit('count', collection, query, options, meta, ack);
socket.emit('update', collection, query, update, options, meta, ack);
socket.emit('remove', collection, query, options, meta, ack);
socket.emit('aggregate', collection, pipeline, options, meta, ack);
Example : JS Client (index.html)
  <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.3/socket.io.js"></script>
  <script>
  //create a socket instance with the regina server address 
  var socket = io('http://localhost:3009/');
  //be aware of the misuse of regina methods
  socket.on('regina_noack_callback_error', (msg) => { console.log(msg); })
  //follow the 'new-msg' tag
  socket.on('new-msg', (res, ctx) => { console.log(res, ctx); });
  //send an insert request to the regina server with the 'new-msg' tag
  socket.emit('insert' //CRUD operation
    , 'messages' //collection
    //query|doc|pipeline
    , { msg: "Hello Regina", sender: "Paris MongoDB User Group" }
    , {} //mongo options
    , { "tags": [{ "val" : "new-msg" }] }  //meta (tags)
    , (err, res, ctx) => { console.log(err, res, ctx); } //ack (callback)
  );
</script>Use of tags
You can use any tag you want except socket.io reserved events. In the
metaparameter, simply add an object containing thetagskey and an array of objects each containing thevalkey.
{"tags":[{"val":"find-users"}, {"val":"@users-coll"}, {"val":"#users"}]}You can also specify the
kind(scope) for each tag :
{"tags":[{"val":"find-users","kind":"emit"}, {"val":"#users","kind":"broadcast"}]}There are 3 kinds of scopes:
emit: sends a message only to the client that sent the request to the server.
broadcast: sends a message to all connected clients except the client that sent the request to the server.
io: sends a message to all connected clients including the client that sent the request to the server. By default the scope isio.