-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path01-find.js
30 lines (28 loc) · 911 Bytes
/
01-find.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var findComplex = require('loopback-postgres-find-complex');
var exclude = [];
var include = [];
module.exports = function(app){
models = app.models();
models.forEach(function(model){
modelName = model.definition.name;
dataSource = model.getDataSource();
if(dataSource != null){
adapter = dataSource.adapter.name;
}
else{
adapter = false;
}
if(exclude.indexOf(modelName) == -1 && adapter == 'postgresql' && (include.length == 0 || include.indexOf(modelName) != -1)){
model.findComplex = function(filter,cb){
complex = new findComplex(model);
complex.init();
complex.find(filter,cb);
// cb();
}
model.remoteMethod('findComplex', {
http: {path: '/findComplex', verb: 'POST'},
accepts: {arg: 'filter', type: 'object'},
returns: {arg: modelName, type: 'array'}});
}
});
}