Skip to content

Commit

Permalink
refactor(example-todo): update files to match output from lb4 model
Browse files Browse the repository at this point in the history
  • Loading branch information
virkt25 committed Jun 28, 2018
1 parent d6f1a64 commit 3fa9b28
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 44 deletions.
6 changes: 6 additions & 0 deletions examples/todo/src/models/_generated/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright IBM Corp. 2017,2018. All Rights Reserved.
// Node module: @loopback/example-todo
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

export * from './todo.base.model';
18 changes: 18 additions & 0 deletions examples/todo/src/models/_generated/todo.base.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright IBM Corp. 2017,2018. All Rights Reserved.
// Node module: @loopback/example-todo
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {Entity, ModelDefinition} from '@loopback/repository';
const modelDef = require('../todo.model.json');

export class TodoBase extends Entity {
static definition = new ModelDefinition(modelDef);

id?: number;
title: string;
desc?: string;
isComplete: boolean;
remindAtAddress?: string;
remindAtGeo?: string;
}
32 changes: 32 additions & 0 deletions examples/todo/src/models/todo.model.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "Todo",
"extends": "Entity",
"properties": {
"id": {
"type": "number",
"id": true,
"required": false
},
"title": {
"type": "string",
"required": true
},
"desc": {
"type": "string",
"required": false
},
"isComplete": {
"type": "boolean",
"required": true,
"defaultValue": "false"
},
"remindAtAddress": {
"type": "string",
"required": false
},
"remindAtGeo": {
"type": "string",
"required": false
}
}
}
46 changes: 2 additions & 44 deletions examples/todo/src/models/todo.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,6 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {Entity, property, model} from '@loopback/repository';
import {TodoBase} from './_generated';

@model()
export class Todo extends Entity {
@property({
type: 'number',
id: true,
})
id?: number;

@property({
type: 'string',
required: true,
})
title: string;

@property({
type: 'string',
})
desc?: string;

@property({
type: 'boolean',
})
isComplete: boolean;

@property({
type: 'string',
})
remindAtAddress: string; // address,city,zipcode

// TODO(bajtos) Use LoopBack's GeoPoint type here
@property({
type: 'string',
})
remindAtGeo: string; // latitude,longitude

getId() {
return this.id;
}

constructor(data?: Partial<Todo>) {
super(data);
}
}
export class Todo extends TodoBase {}

0 comments on commit 3fa9b28

Please sign in to comment.