Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLI] How to use custom schema with postgres connector in loopback 4 #2388

Closed
MrJim-06 opened this issue Feb 14, 2019 · 4 comments
Closed

[CLI] How to use custom schema with postgres connector in loopback 4 #2388

MrJim-06 opened this issue Feb 14, 2019 · 4 comments
Assignees

Comments

@MrJim-06
Copy link

MrJim-06 commented Feb 14, 2019

I'm use this code to use custom schema in todo.model.ts file

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

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

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

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

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

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


  constructor(data?: Partial<Todo>) {
    super(data);
  }
}

this is error

Unhandled error in GET /todos: 500 error: relation "public.todo" does not exist
    at Connection.parseE (C:\Users\develop\Desktop\test-project\loopback-postgres\node_modules\pg\lib\connection.js:555:11)
    at Connection.parseMessage (C:\Users\develop\Desktop\test-project\loopback-postgres\node_modules\pg\lib\connection.js:380:19)
    at Socket.<anonymous> (C:\Users\develop\Desktop\test-project\loopback-postgres\node_modules\pg\lib\connection.js:120:22)
    at Socket.emit (events.js:189:13)
    at addChunk (_stream_readable.js:284:12)
    at readableAddChunk (_stream_readable.js:265:11)
    at Socket.Readable.push (_stream_readable.js:220:10)
    at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
@dhmlau
Copy link
Member

dhmlau commented Feb 14, 2019

@MrJim-06 , please use settings instead of options.
For details, see #2134 (comment).
Let me see how we should update the documentation. Thanks!

@dhmlau dhmlau self-assigned this Feb 14, 2019
@dhmlau
Copy link
Member

dhmlau commented Feb 14, 2019

If this resolves your question, please let me know and I can close this ticket.
#2134 can be used to improve the docs.

@MrJim-06
Copy link
Author

MrJim-06 commented Feb 15, 2019

@dhmlau yes that's worked thank you.

@dhmlau
Copy link
Member

dhmlau commented Feb 15, 2019

Closing it as resolved.

@dhmlau dhmlau closed this as completed Feb 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants