You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following instructions assume that you already have Node.js installed.
# Clone the repository
git clone git://github.com/numtel/sails-mysql-live-select-chat-example.git
# Switch to new directorycd sails-mysql-live-select-chat-example
# Install dependencies
npm install
# Update MySQL connection settings in editor
vim config/connections.js
# Lift Sails (or simply 'sails lift' if installed)
node app.js
Explanation
The sails-mysql-live-select adapter is configured in config/connections.js in addition to the sails-mysql adapter. View Source
Models are configured by default to use both the mysql and liveMysql connections. View Source
A method called liveStream is added to the ChatController to enable subscribing and unsubscribing from the chat message stream. The liveFind method added to each model accepts two arguments: the find query options, and an optional data invalidation callback as defined in mysql-live-select. View Source
The Angular controller performs a socket GET request on initialization to /chat/liveStream. On unsubscribing, a POST request containing a parameter unsubscribe set to true is performed to stop receiving updates. View Source
Result set differences arrive on the client in the format provided by mysql-live-select and are applied to the data cache array using the applyDiff function copied from the server-side code for client-side usage. View Source
License
Unlicense
About
SailsJS example application with real time MySQL result sets