This repository has been archived by the owner on Apr 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 54
/
root.js
45 lines (44 loc) · 1.26 KB
/
root.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright IBM Corp. 2015,2017. All Rights Reserved.
// Node module: loopback-example-relations
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
module.exports = function(app) {
var router = app.loopback.Router();
router.get('/', function(req, res, next) {
app.models.Customer.findOne({
where: {
name: 'Customer A'
}}, function(err, customer) {
if (err) return next(err);
res.render('index', {customer: customer});
});
});
router.get('/email', function(req, res, next) {
app.models.Customer.findOne({
where: {
name: 'Larry Smith'
}}, function(err, customer) {
if (err) return next(err);
res.render('email', {customer: customer});
});
});
router.get('/address', function(req, res, next) {
app.models.Customer.findOne({
where: {
name: 'John Smith'
}}, function(err, customer) {
if (err) return next(err);
res.render('address', {customer: customer});
});
});
router.get('/account', function(req, res, next) {
app.models.Customer.findOne({
where: {
name: 'Mary Smith'
}}, function(err, customer) {
if (err) return next(err);
res.render('account', {customer: customer});
});
});
app.use(router);
};