The sample snippets shown in this repo is being used with Postgresql database, but it should work similarly with other databases.
If I have a table name or column name that is different from the model name and property, what should I change?
The model name generally maps to the table name. You can make the model associate with a different table name by specifying it in the @model
decorator settings
property.
@model({
settings: {
postgresql: {
table: 'TODO_123',
},
},
})
export class Todo extends Entity {
Similarly for column name.
@property({
type: 'string',
required: true,
postgresql: {
columnName: 'TODO_TITLE',
},
})
title: string;
See models\todo.model.ts
.
You can use the generated: true
settings. Make sure that the id field is not an optional variable.
@property({
type: 'string',
id: true,
generated: true,
})
custid: string;
See models\customer.model.ts
.