hello guys i m new to loopback and don't know how i can link or include model in root.js for eg :-
var next = require( '../../common/models/emplyee');
module.exports = function(app) {
app.get('/get',next.getemployeee );
};
and in emplyee.js
module.exports = function(Emplyee) {
Emplyee.getemployeee = function(callback) {
// TODO
callback(null,{data:"qwe"});
};
};
i know i can use this kind of code in express but i want to know how i can use this code in loopback i tried but it throw error var next = require( '../../common/models/emplyee'); is this correct way or i missing something
答案 0 :(得分:1)
@rocky可能是这样的
var next = require( '../../common/models/emplyee');
var emp=app.models.Emplyee;
var check=new next(emp)
module.exports = function(app) {
app.get('/get',check.getemployeee() );
};
module.exports = function(Emplyee) {
Emplyee.getemployeee = function() {
var data="hii";
return data
};
return Emplyee
};
i think it not a good way to do. i haven't try but it should work