loopback-next icon indicating copy to clipboard operation
loopback-next copied to clipboard

[CLI] Adding nested configurations to model settings

Open yanamg7 opened this issue 7 years ago • 4 comments

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:")

yanamg7 avatar Mar 03 '19 11:03 yanamg7

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.

marioestradarosa avatar Mar 04 '19 00:03 marioestradarosa

Hi Mario, Yes, I’d like with my pleasure. I also put my request to be added as LoopBack.next contributor in https://github.com/strongloop/loopback-next/issues/110 but still waiting.

From: Mario Estrada [email protected] Sent: Monday, March 4, 2019 2:07 AM To: strongloop/loopback-next [email protected] Cc: Yana Agapeyev [email protected]; Mention [email protected] Subject: Re: [strongloop/loopback-next] [CLI] Adding nested configurations to model settings (#2522)

EXTERNAL MAIL: [email protected]mailto:[email protected]

Hi @yanamg7https://github.com/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.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/strongloop/loopback-next/issues/2522#issuecomment-469080563, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AsaJBTaSmJUWMQ21d2FmtEMDNY6pmQx0ks5vTGO-gaJpZM4ba7ZS.

yanamg7 avatar Mar 04 '19 08:03 yanamg7

@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!

dhmlau avatar Mar 04 '19 20:03 dhmlau

Should be fixed via https://github.com/strongloop/loopback-next/pull/2843.

nabdelgadir avatar May 24 '19 15:05 nabdelgadir