2016-04-06 14:51:49 +00:00
|
|
|
// Copyright IBM Corp. 2013,2016. All Rights Reserved.
|
|
|
|
// Node module: loopback-datasource-juggler
|
|
|
|
// This file is licensed under the MIT License.
|
|
|
|
// License text available at https://opensource.org/licenses/MIT
|
|
|
|
|
2013-07-30 21:10:03 +00:00
|
|
|
var ModelBuilder = require('../../loopback-datasource-juggler').ModelBuilder;
|
2013-07-11 21:24:47 +00:00
|
|
|
var modelBuilder = new ModelBuilder();
|
|
|
|
|
|
|
|
// simplier way to describe model
|
|
|
|
var User = modelBuilder.define('User', {
|
2014-01-24 17:09:53 +00:00
|
|
|
name: String,
|
|
|
|
bio: ModelBuilder.Text,
|
|
|
|
approved: Boolean,
|
|
|
|
joinedAt: Date,
|
|
|
|
age: Number,
|
|
|
|
address: {
|
|
|
|
street: String,
|
|
|
|
city: String,
|
|
|
|
state: String,
|
|
|
|
zipCode: String,
|
|
|
|
country: String
|
|
|
|
},
|
|
|
|
emails: [
|
|
|
|
{
|
|
|
|
label: String,
|
|
|
|
email: String
|
|
|
|
}
|
|
|
|
],
|
|
|
|
friends: [String]
|
2013-07-11 21:24:47 +00:00
|
|
|
});
|
|
|
|
|
2013-07-13 01:59:43 +00:00
|
|
|
var user = new User({name: 'Joe', age: 20, address: {street: '123 Main St', 'city': 'San Jose', state: 'CA'},
|
2014-01-24 17:09:53 +00:00
|
|
|
emails: [
|
|
|
|
{label: 'work', email: 'xyz@sample.com'}
|
|
|
|
],
|
|
|
|
friends: ['John', 'Mary']});
|
2014-02-14 07:42:21 +00:00
|
|
|
console.log(user);
|
2013-07-12 19:36:14 +00:00
|
|
|
console.log(user.toObject());
|