Store socket created by socket.io in MongoDB

I am trying to create an application based on Node.js, using the Express, Socket.io and MongoDB (by mongoose / node mongo native driver).

My problem is that, along with establishing a connection to the client by WebSockets also I get additional informations that the storage and processing will be the best within database. Then with the arrival of the events I am looking for client on the basis of additional information and by sockets I send notifications to those clients.

My question - is there a possibility to store the objects created with the socket connection to the database?

If not, my idea is to store them in an array together with an additional variable that will allow them to find through found items in the database for additional information. Am I right?

client --> create conection --> send data --> server --> search DB for matching data --> match sockets to founded data --> send notifactions by founded sockets

Sincerely

For anybody who comes across this via Google, it seems there is now a socket.io-mongo module that handles this.

you could keep a list of sockets and what node process they belong to in mongodb and then message that process when a message needs to be delivered to a specific socket. Something like each message having

{delivery_to:all} or {delivery_to:[1, 2, 3, 4]} where the number is a socket id.

But the elegant way is to use a capped collection in mongodb and have all processes listen to the collection and handle any messages belonging to that process. A good description of a queue implementation using mongodb can be found here.

http://www.10gen.com/presentations/mongosv-2011/mongodb-as-a-message-queue