dresende / node-orm2

Object Relational Mapping
http://github.com/dresende/node-orm2
MIT License
3.07k stars 379 forks source link

Integrate ORM2 with Socket.io #748

Open guicouto opened 7 years ago

guicouto commented 7 years ago

Is it possible to integrate socket.io and node-orm2?

What I actually want is use this way:

1) Create a connection global: In my server.js create a global connection, as I do using express, but in express I call in req

2) Inside socket.io, for example

socket.on('send_message', function(socket){ orm_global.db.models.messages.create({ message: my_message_var, date: new Date(), }); });

PS: I'm using MySQL.

Thanks in advance. Guilherme Couto