2016-05-03 22:50:21 +00:00
|
|
|
// Copyright IBM Corp. 2014,2016. All Rights Reserved.
|
|
|
|
// Node module: loopback
|
|
|
|
// This file is licensed under the MIT License.
|
|
|
|
// License text available at https://opensource.org/licenses/MIT
|
|
|
|
|
2016-09-16 19:31:48 +00:00
|
|
|
var g = require('../../lib/globalize');
|
2014-02-19 19:44:16 +00:00
|
|
|
var loopback = require('../../');
|
|
|
|
var client = loopback();
|
|
|
|
var CartItem = require('./models').CartItem;
|
|
|
|
var remote = loopback.createDataSource({
|
|
|
|
connector: loopback.Remote,
|
2016-04-01 09:14:26 +00:00
|
|
|
url: 'http://localhost:3000',
|
2014-02-19 19:44:16 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
client.model(CartItem);
|
|
|
|
CartItem.attachTo(remote);
|
|
|
|
|
|
|
|
// call the remote method
|
|
|
|
CartItem.sum(1, function(err, total) {
|
2016-06-07 14:48:28 +00:00
|
|
|
g.log('result:%s', err || total);
|
2014-02-19 19:44:16 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// call a built in remote method
|
|
|
|
CartItem.find(function(err, items) {
|
2016-08-16 04:52:44 +00:00
|
|
|
console.log(items);
|
2014-02-19 19:44:16 +00:00
|
|
|
});
|