简体   繁体   中英

How do I access loopback data in the server?

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!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM