-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Docs: how to configure a custom table/collection name different from model class name #2197
Comments
@johntom Please reference to this issue #2134 and https://github.com/strongloop/loopback/issues/4086#issuecomment-445015678 @model({
settings: {
postgresql: { // replace postgresql with mongo or mongodb I think
table: 'customer',
},
},
}) |
Thanks, that did it! @model({
settings: {
mongodb: {
collection: 'todo',
}
},
}) export class Todo extends Entity {
@property({
type: 'string',
id: true,
})
id?: string;
@property({
type: 'string',
required: true,
})
title: string;
@property({
type: 'string'
})
desc?: string;
@property({
type: 'boolean',
})
isComplete?: boolean;
constructor(data?: Partial<Todo>) {
super(data);
}
} |
Let's improve our documentation to make it easier for future users to find how to customize database table names. I am going to reopen this issue and label it as "Docs". |
Any volunteers to contribute this documentation improvement? |
Hello @bajtos. I would like to help on this.
Another concern is that, it is the fact that |
Sounds good to me 👍
This can be confusing. Under the hood, loopback-datasource-juggler is (and always has been) using the name
It would be great to have documentation on model settings (options) in LB4 section of our doc site, but I see how that can be more work that you may be willing to contribute. As a quick improvement, maybe it's enough to add a link pointing readers of LB4 docs to the LB3 doc page describing model settings? |
Description / Steps to reproduce
loopback 4
node 10.14.2
npm 6.4.1
win10
I have a pre existing mongo db database containing all lower case collections. The scaffolding used in tutorial examples assumes a Proper Case collection. I would like to use a lowercase collection name, from Todo > todo
Current Behavior
The collection appearas as Todo in mongo following the example given
Expected Behavior
I want to the model, controller and repository use the lowercase name of todo and not Todo..
Acceptance Criteria (Added by LoopBack team)
@model
decorator when the model name is different from the table name@property
decorator when the property name is different from the column name.Note: This sample repo https://github.com/dhmlau/loopback4-example-todo-customized can be used as a reference.
Things to be discussed:
The text was updated successfully, but these errors were encountered: