SC-CRUD-MYSQL
Changelog
-
0.6.2
- Added ability to use the LIKE operator
-
0.6.1
- Added query function
-
0.6.0
- Added 3 more functions
-
0.5.0
- Better SQL injection protection and tests added
-
0.4.7
- Added order_by for reads.
-
0.4.0
- Added expressions and joins to 'read'.
-
0.3.2
- Fixed the documentation.
-
0.3.0
- Allow for broadcasting back to clients.
-
0.2.3
- Fixed the error with CREATE.
-
0.2.2
- Added limit and offset to READ.
-
0.2.1
- Added the ability to query server-side.
-
0.1.1
- Added the ability to setup ecryption verification as well.
-
0.1.0
- Finished intial build. Let me know what you think!
- I've added encryption. Check out the options below for more details.
sc-crud-mysql
Realtime CRUD data management layer/plugin for SocketCluster using MySQL as the database.
Somewhat of an example build above in the examples folder.
Setup
This module is a plugin for SocketCluster, so you need to have SC installed: http://socketcluster.io/#!/docs/getting-started Once SC is installed and you have created a new SC project, you should navigate to your project's main directory and run:
npm install sc-crud-mysql --save
Initial Instructions
Setup your database however you wish. Allow me to suggest db-migrate to design your database.
Attaching to your workers (server-side)
Now we need to attach the SC-CRUD-Mysql listener to the worker channels. Type in the following code in the worker.js file
var scCrudMysql = require module.exports.run =
Using client side
var socket = socketCluster socket socket socket // If all you pass in is a table then you get 'SELECT * FROM ${table}'socket socket // Create a record in the database that is unique (i.e. check to ensure it's going to be a unique record.)socket // Grab the first record in the database with a conditional (optional)socket // Grab the records in the database with a conditional (optional)socket // Grab the records in the database with a conditional (optional)socket // If broadcasting back to all clients (defaults to true)var createWatcher = socketcreateWatchervar updateWatcher = socketupdateWatchervar deleteWatcher = socketdeleteWatcher
Write client-side models to handle complex operations =). So much win!
SC-CRUD-Mysql Options
All options
Encryption is handled with bcrypt if no function is passed in. That is the preferred method but feel free to pass in your own function if you wish.
scCrudMysql
Not using cache for database
scCrudMysql
Using cache
scCrudMysql
Using your own pool
scCrudMysql
Querying server-side
You can query server-side if you need to. You use this just like the mysql module (pool)
var sc_crud_mysql = scCrudMysql sc_crud_mysql
License
MIT
Contributors
- Nick Kotenberg github profile