Open jmls opened 6 years ago
so, I tried
./node_modules/.bin/lb-sdk server/server src/app/sdk -n enabled
and
./node_modules/.bin/lb-sdk server/server src/app/sdk -n orm
but both give an error
readline.js:1021
throw err;
^
TypeError: ejs:33
31| public <%- normalizeMethodName(methodName) %>$ = this.actions$
32| .ofType(<%- modelName %>ActionTypes.<%- upperCasedMethodName(methodName) %>).pipe(
>> 33| mergeMap((action: LoopbackAction) =>
34| this.<%- modelName.toLowerCase() %>.<%- normalizeMethodName(methodName) %>(<%- buildMethodParamsFromPayload(model, methodName, action.accepts) %>).pipe(
35| <% if (methodName.match(/(^__delete)/)) { -%>
36| map((response: any) => new <%- modelName %>Actions.<%- normalizeMethodName(methodName) %>Success(action.payload, action.meta)),
Cannot read property 'targetClass' of undefined
at eval (eval at exports.compile (/home/jmls/development/rtb-dashboard/node_modules/@mean-expert/loopback-sdk-builder/node_modules/ejs/lib/ejs.js:242:14), <anonymous>:40:625)
anyone ? :)
@jmls .... I think in the following days we will see some docs from @JonnyBGod.. He is quite busy with an upcoming conf, but he will be sending those docs soon.
Cheers Jon
any luck on the docs or the above error ?
my usual weekly bump ;) hoping to understand why I'm getting the error when trying to generate code ...
@jmls I would like to help more on this but I don't have idea how to use this neither... Lol,
But, the unit tests are working, have you tried to run the test environment and see how @JonnyBGod wired the tests you might understand how it is working
yeah - I understand - but right now my problem is that I can't even get the code to generate, let alone play with and test ;) I'll cross fingers and hope that @JonnyBGod gets sufficiently annoyed by the number of pings and comes to see what all the fuss is about :+1:
FTR I found out today that the error in the OP occurs if your relation names have underscores in them.
The generator performs .split('_').pop()
to get the action name which means relations with underscores cause errors.
@zbarbuto thanks for the heads-up . @JonnyBGod , any chance you could have a look at this and the docs ?
except for the fact I have no relations with _ in the name ... dammit ...
@jmls Can you provide a repo or send me your project to check out what might be causing the problem?
@zbarbuto Thanks for reporting. I will investigate a better way to do it to enable underscores for relation names.
@zbarbuto you should be able to use underscores in your relation names after https://github.com/mean-expert-official/loopback-sdk-builder/pull/547 is released.
Just make sure you do not use double underscore.
@JonnyBGod is there any plan to allow double underscore methods?
The only reason I ask is because the separators for methods accessing related models is double underscore.
Version 2: https://loopback.io/doc/en/lb2/Accessing-related-models.html Version 3: https://loopback.io/doc/en/lb3/Accessing-related-models.html
dammit, I guess this was never fixed ? Hit it again, wanting to play with ngrx :)
I've found the base problem - it's when you have a scope then you get this error.
I've fixed it by adding
var targetName = model.sharedClass.ctor.relations[action.name.split('__').pop()] || {}
under methodName = action.name.split
(line 20 of shared/effects/model.ejs) and replacing all other instances of
model.sharedClass.ctor.relations[action.name.split('__').pop()]
with targetName
What version of this module are you using?
Please add a description for your issue:
Installed the latest version, eager to use the cool ngrx features ... but can't find any docs ... am I going blind ?
:)