GitXplorerGitXplorer
r

sequelize-socket-interface

public
0 stars
0 forks
0 issues

Commits

List of commits on branch master.
Verified
1c96d6597c050141537c1f6ce3b68a4dcc59ec69

Update README.md

rrichardpringle committed 7 years ago
Verified
40f6728b1c36b9695ee8015ed5529f1cc227c88c

Update README.md

rrichardpringle committed 7 years ago
Unverified
4506791d3ad5c083f22b582af0379741fd726242

Add initial server and client logic.

rrichardpringle committed 7 years ago
Verified
f7ed6b0ba335a013211bb6d561dab1bb8d672a30

Initial commit

rrichardpringle committed 7 years ago

README

The README file for this repository.

squelize-socket-interface

example

const router = require('express').Router();

const Client = require('sequelize-socket-interface');

router.get('/students/{student_id}/parents/', function(req, res) {
  let clientModel = new Client(3000); // takes the same parameters as Socket.prototype.connect
  
  clientModel.MySql({
    tenant: 'cowichan-secondary',
    model: 'Student',
    method: 'findById',
    params: req.params.student_id
  }).then(response => { // response is the object returned by student.get()
    return clientModel.data({ // .data for an instance, .dataSets for array of instances from findAll() for ex.
      tenant: 'cowichan-secondary',
      model: 'student', // follows the convention of instances starting with lower-case letter (I should change this)
      method: 'getParents',
      params: []
    });
  }).then(parents => {
    if (!parents.length) {
      return res.sendStatus(404);
    } 
    
    return res.json(parents);
  });
});