Loopback-next: lb4 specifying table name

Created on 29 Nov 2018  路  3Comments  路  Source: strongloop/loopback-next

my existing database table name "foo_bar". I generate a model "fooBar".

500 error: relation "schema.foobar" does not exist

where I can define the tablename? I does see reference on doc in lb4. please help. thanks

Most helpful comment

@rexliu0715 , you can add the settings in the model decorator.
In the example below, my model name is Customer2 but the table name is customer in my postgresql datasource.

@model({
  settings: {
    postgresql: {
      table: 'customer',
    },
  },
})
export class Customer2 extends Entity {

Hope it helps. If that's the case, do you mind submitting a PR to improve our docs? Thanks!

All 3 comments

@rexliu0715 , you can add the settings in the model decorator.
In the example below, my model name is Customer2 but the table name is customer in my postgresql datasource.

@model({
  settings: {
    postgresql: {
      table: 'customer',
    },
  },
})
export class Customer2 extends Entity {

Hope it helps. If that's the case, do you mind submitting a PR to improve our docs? Thanks!

Closing as a duplicate of #2134.

Was this page helpful?
0 / 5 - 0 ratings