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] Adding nested configurations to model settings #2522

Closed
yanamg7 opened this issue Mar 3, 2019 · 4 comments
Closed

[CLI] Adding nested configurations to model settings #2522

yanamg7 opened this issue Mar 3, 2019 · 4 comments
Labels

Comments

@yanamg7
Copy link
Contributor

yanamg7 commented Mar 3, 2019

Description / Steps to reproduce / Feature proposal

We need to add some configuration to the model settings like

@model({ 
  settings: {
    mongodb: {
      collection: 'clients',
    },
  },
})

Current Behavior

In configuration.JSON I put:

"modelSettings": {
			"mongodb": {
                                 "collection": "clients"
                          }
  },

The CLI generated model has a string instead of JSON:

@model({ settings: { "mongodb": { "collection": "clients" } } })

Expected Behavior

The generated output should be

@model({ settings: { 
                     mongodb: { 
                            collection: "clients"
            } 
    } })

I think in @loopback\cli\generators\model\templates\model.ts.ejs
instead of JSON.stringify(modelSettings) should be JSON.stringify(modelSettings).replace(/\"([^(\")"]+)\":/g,"$1:")

@marioestradarosa
Copy link
Contributor

Hi @yanamg7, thank you 👍 for pointing it out and suggesting the solution. Would you like to contribute to the proposed solution?. I believe that aside from changing the suggested line, we will need an acceptance test to make sure it solves the issue.

@yanamg7
Copy link
Contributor Author

yanamg7 commented Mar 4, 2019 via email

@dhmlau
Copy link
Member

dhmlau commented Mar 4, 2019

@yanamg7, thanks for your interest in contributing. We'll catch up on the issue #110. :) This is mostly to add you to be in the @strongloop/loopback-next github team, so that we can use this handle to ask for our users' feedback. It's definitely not a blocker to contribute. :)

We've just created a step-by-step guide in contributing to LB4. Please take a look as well: https://loopback.io/doc/en/lb4/submitting_a_pr.html. Looking forward to your PR!

yanamg7 added a commit to yanamg7/loopback-next that referenced this issue Mar 17, 2019
…template

prepare the  string of all model settings and use it in the template, fix one test and add the new
one to test this case

fix loopbackio#2522
yanamg7 added a commit to yanamg7/loopback-next that referenced this issue Mar 18, 2019
…template

prepare the  string of all model settings and use it in the template, fix one test and add the new

fix loopbackio#2522
@nabdelgadir
Copy link
Contributor

Should be fixed via #2843.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants