{"id":18304598,"url":"https://github.com/numtel/sails-mysql-live-select-chat-example","last_synced_at":"2025-04-09T10:36:54.014Z","repository":{"id":150130937,"uuid":"44411291","full_name":"numtel/sails-mysql-live-select-chat-example","owner":"numtel","description":"SailsJS example application with real time MySQL result sets","archived":false,"fork":false,"pushed_at":"2015-10-19T15:50:24.000Z","size":328,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-15T04:42:37.354Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/numtel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-16T21:22:31.000Z","updated_at":"2017-08-25T22:22:47.000Z","dependencies_parsed_at":"2023-04-10T13:11:51.982Z","dependency_job_id":null,"html_url":"https://github.com/numtel/sails-mysql-live-select-chat-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numtel%2Fsails-mysql-live-select-chat-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numtel%2Fsails-mysql-live-select-chat-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numtel%2Fsails-mysql-live-select-chat-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numtel%2Fsails-mysql-live-select-chat-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/numtel","download_url":"https://codeload.github.com/numtel/sails-mysql-live-select-chat-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248021416,"owners_count":21034661,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T15:29:30.192Z","updated_at":"2025-04-09T10:36:53.985Z","avatar_url":"https://github.com/numtel.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sails-mysql-live-select-chat-example\n\nA [Sails](http://sailsjs.org) chat room application that uses [the `sails-mysql-live-select` NPM package wrapper](https://github.com/numtel/sails-mysql-live-select) in order to provide live (real time) result sets for models.\n\nThis example uses [AngularJS](https://angularjs.org/) as a front-end framework. The original inspiration for this example was provided by [Maanga Labs' Sockets in Sails example application](https://github.com/maangalabs/socket-in-sails). Also, [a tutorial is available for the original Maanga Labs socket example](http://maangalabs.com/blog/2014/12/04/socket-in-sails/).\n\n## Installation\n\nThe following instructions assume that you already have Node.js installed.\n\n```bash\n# Clone the repository\ngit clone git://github.com/numtel/sails-mysql-live-select-chat-example.git\n# Switch to new directory\ncd sails-mysql-live-select-chat-example\n# Install dependencies\nnpm install\n# Update MySQL connection settings in editor\nvim config/connections.js\n# Lift Sails (or simply 'sails lift' if installed)\nnode app.js\n```\n\n## Explanation\n\n1. The `sails-mysql-live-select` adapter is configured in `config/connections.js` in addition to the `sails-mysql` adapter. [View Source](config/connections.js)\n\n2. Models are configured by default to use both the `mysql` and `liveMysql` connections. [View Source](config/models.js)\n\n3. 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](https://github.com/numtel/mysql-live-select#condition-function) as defined in mysql-live-select. [View Source](api/controllers/ChatController.js)\n\n4. 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](assets/index.html)\n\n5. 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](assets/js/applyDiff.js)\n\n## License\n\nUnlicense\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnumtel%2Fsails-mysql-live-select-chat-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnumtel%2Fsails-mysql-live-select-chat-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnumtel%2Fsails-mysql-live-select-chat-example/lists"}