2018-01-03 04:05:53 +00:00
|
|
|
// Copyright IBM Corp. 2013,2018. All Rights Reserved.
|
2016-05-03 22:50:21 +00:00
|
|
|
// Node module: loopback
|
|
|
|
// This file is licensed under the MIT License.
|
|
|
|
// License text available at https://opensource.org/licenses/MIT
|
|
|
|
|
2016-11-15 21:46:23 +00:00
|
|
|
'use strict';
|
2016-09-16 19:31:48 +00:00
|
|
|
var g = require('../../lib/globalize');
|
2013-07-16 17:49:25 +00:00
|
|
|
var loopback = require('../../');
|
|
|
|
var app = loopback();
|
2013-05-01 19:11:43 +00:00
|
|
|
|
2013-07-16 17:49:25 +00:00
|
|
|
app.use(loopback.rest());
|
2013-05-01 19:11:43 +00:00
|
|
|
|
2013-05-24 22:08:23 +00:00
|
|
|
var schema = {
|
2016-04-01 09:14:26 +00:00
|
|
|
name: String,
|
2013-05-24 22:08:23 +00:00
|
|
|
};
|
2013-05-01 19:11:43 +00:00
|
|
|
|
2016-11-15 21:46:23 +00:00
|
|
|
app.dataSource('db', {connector: 'memory'});
|
2016-06-03 20:51:48 +00:00
|
|
|
var Color = app.registry.createModel('color', schema);
|
2016-11-15 21:46:23 +00:00
|
|
|
app.model(Color, {dataSource: 'db'});
|
2013-05-24 22:08:23 +00:00
|
|
|
|
2016-11-15 21:46:23 +00:00
|
|
|
Color.create({name: 'red'});
|
|
|
|
Color.create({name: 'green'});
|
|
|
|
Color.create({name: 'blue'});
|
2013-05-01 19:11:43 +00:00
|
|
|
|
|
|
|
app.listen(3000);
|
|
|
|
|
2016-06-07 14:48:28 +00:00
|
|
|
g.log('a list of colors is available at {{http://localhost:3000/colors}}');
|