loopback/example/simple-data-source/app.js

29 lines
646 B
JavaScript
Raw Normal View History

2016-05-04 00:10:46 +00:00
// Copyright IBM Corp. 2013,2016. All Rights Reserved.
// Node module: loopback
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
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
var dataSource = app.dataSource('db', {adapter: 'memory'});
var Color = dataSource.define('color', {
'name': String
});
Color.create({name: 'red'});
Color.create({name: 'green'});
Color.create({name: 'blue'});
Color.all(function () {
console.log(arguments);
});
app.listen(3000);
console.log('a list of colors is available at http://localhost:3000/colors');