2013-07-16 17:49:25 +00:00
|
|
|
var loopback = require('../../');
|
|
|
|
var app = loopback();
|
2013-05-24 14:59:23 +00:00
|
|
|
|
2013-07-16 17:49:25 +00:00
|
|
|
app.use(loopback.rest());
|
2013-05-24 14:59:23 +00:00
|
|
|
|
|
|
|
|
2016-04-01 09:14:26 +00:00
|
|
|
var dataSource = app.dataSource('db', { adapter: 'memory' });
|
2013-05-24 14:59:23 +00:00
|
|
|
|
|
|
|
var Color = dataSource.define('color', {
|
2016-04-01 09:14:26 +00:00
|
|
|
'name': String,
|
2013-05-24 14:59:23 +00:00
|
|
|
});
|
|
|
|
|
2016-04-01 09:14:26 +00:00
|
|
|
Color.create({ name: 'red' });
|
|
|
|
Color.create({ name: 'green' });
|
|
|
|
Color.create({ name: 'blue' });
|
2013-05-24 14:59:23 +00:00
|
|
|
|
2016-04-01 09:14:26 +00:00
|
|
|
Color.all(function() {
|
2013-05-24 14:59:23 +00:00
|
|
|
console.log(arguments);
|
|
|
|
});
|
|
|
|
|
|
|
|
app.listen(3000);
|
|
|
|
|
2014-11-13 01:08:08 +00:00
|
|
|
console.log('a list of colors is available at http://localhost:3000/colors');
|