Reputation: 1397
I am currently using loopback (http://loopback.io/) to run an application, while most of the data is accessed on the front end using the angular SDK I also have a socket connection where I'd like to access this data.
In server/server.js I've got
var loopback = require('loopback');
var app = module.exports = loopback();
if (require.main === module) {
//app.start();
app.io = require('socket.io')(app.start());
app.io.on('connection', gameControl.onConnect);
}
Which runs the following in server/controllers/gameController.js
exports.onConnect = function(socket) { ... }
In this file I'd like to call my models, something like
Users.find({}, function(res) {
//Do some stuff
});
How do I do this? I don't know what to 'require' :/
Any help appreciated!
Upvotes: 0
Views: 477
Reputation: 2781
Model.find({where: {name: 'John', functoin(err, models)...
is an example.
See more at http://docs.strongloop.com/display/public/LB/Querying+data#Queryingdata-Nodesyntax
Upvotes: 1