When using slc loopback:relation, I get [object Promise] error
Hi good morning everyone,
I am on Windows 7. and npm version is 3.6.0. I was trying to play with slc loopback:relation concept. Whenever, I try to establish a has-many relationship between two models, I run into the [object Promise] showing up in red color at the point where I was prompted to enter the name of the relationship. I spent several hours trying to figure out what may be causing the issue.
Below is the example that I was trying to do - Please see the last line, where it says, [object Promise] - I am not able to get past this issue no matter whatever I enter.
Any clues will be greatly appreciated
C:\sairam\OMSaiRamC\FullStack\Session - 5\Week 4\loopback-server>slc loopback:model
? Enter the model name: Test1
? Select the data-source to attach undefined to: MongoDB (mongodb)
? Select model's base class PersistedModel
? Expose Test2 via the REST API? Yes
? Custom plural form (used to build REST URL):
? Common model or server only? common
Let's add some Test1 properties now.
Enter an empty property name when done.
? Property name: Name
invoke loopback:property
? Property type: string
? Required? Yes
? Default value[leave blank for none]:
Let's add another Test1 property.
Enter an empty property name when done.
? Property name: Description
invoke loopback:property
? Property type: string
? Required? Yes
? Default value[leave blank for none]:
Let's add another Test1 property.
Enter an empty property name when done.
? Property name:
C:\sairam\OMSaiRamC\FullStack\Session - 5\Week 4\loopback-server>slc loopback:model
? Enter the model name: Test2
? Select the data-source to attach undefined to: MongoDB (mongodb)
? Select model's base class PersistedModel
? Expose Test2 via the REST API? Yes
? Custom plural form (used to build REST URL):
? Common model or server only? common
Let's add some Test2 properties now.
Enter an empty property name when done.
? Property name: Price
invoke loopback:property
? Property type: string
? Required? Yes
? Default value[leave blank for none]:
Let's add another Test2 property.
Enter an empty property name when done.
? Property name: Label
invoke loopback:property
? Property type: string
? Required? Yes
? Default value[leave blank for none]:
Let's add another Test2 property.
Enter an empty property name when done.
? Property name:
C:\sairam\OMSaiRamC\FullStack\Session - 5\Week 4\loopback-server>slc loopback:relation
? Select the model to create the relationship from: Test1
? Relation type: has many
? Choose a model to create a relationship with: Test2
? Enter the property name for the relation: (test2s)
>> [object Promise]
@subchal : Hi, could you please let me know what strongloop version you have:
you can grab the output of slc -v and post it here for me.
Hi Good morning, please see below
C:\sairam\OMSaiRamC\FullStack\Session - 5\Week 4\loopback-server2>npm -v 3.6.0
C:\sairam\OMSaiRamC\FullStack\Session - 5\Week 4\loopback-server2>slc -v strongloop v6.0.1 (node v5.7.0) ├── [email protected] (fb756f2) ├── [email protected] (a98f310) ├── [email protected] (9b29df0) ├── [email protected] (62e539b) ├── [email protected] (6ab604c) ├── [email protected] (f8c2339) ├── [email protected] (28c261d) ├─┬ [email protected] │ └── [email protected] (ec2d95b) ├── [email protected] (81311b3) ├── [email protected] └── [email protected]
Hi Good afternoon, just checking to see if you need any further information and any anticipated time frame on when you may be able to suggest next steps. Thanks in advance.
Hi Good morning Gunipan, Just checking if you have any further guidance on the above noted issue ?
@subchal : That seems to be a bug as I can reproduce it. We will update you on the status when it's fixed. Meanwhile, would you like to submit a patch.
Hi Gunjpan good morning - Unfortunately, I don't know how to fix it. Hence, I won't be able to submit a patch. In the meanwhile, Is there a previous version of the connector, for MongoDB, that is available for me to use ? Also, can you please let me know how long it will take to fix the bug ? Please let me know. Thanks for your help
@subchal : It's fixed here: https://github.com/strongloop/generator-loopback/pull/192
It's fixed, not sure if it's released on npm, you can directly install generator-loopback from GH repo
@subchal: it's not connector specific, it was an issue with the relation generator. If you like, you can create hasMany relation programmatically as well, more here
Hi Good morning Gunjpan,
I see above "@subchal : It's fixed here: strongloop/generator-loopback#192 It's fixed, not sure if it's released on npm, you can directly install generator-loopback from GH repo" -
Can you please provide further instructions, such as, do I need to do npm uninstall loopback-connector-mongodb first, before I do npm install generator-loopback ? Also, I am bit new to Git REpo. Trying to figure out how to do the install directly from Git Repo. Any pointers will be greatly appreciated.
Verified.
Verification steps:
- [x] Create a
slc loopbackapp - [x] Create two models
test1andtest2usingslc loopback:model - [x] Create a has many relationship between
test1andtest2usingslc loopback:relationas shown below:
Hi ssh24 good morning - Can you please provide some instructions on how i can get this fix onto my local workstation ? Can you please provide further instructions, such as, do I need to do npm uninstall loopback-connector-mongodb first, before I do npm install generator-loopback ? Also, I am bit new to Git REpo. Trying to figure out how to do the install directly from Git Repo. Any pointers will be greatly appreciated.
@subchal: Install generator-loopback from its gitHub repo using npm. See how to do it here
Can you please provide further instructions, such as, do I need to do npm uninstall loopback-connector-mongodb first, before I do npm install generator-loopback
NO. you just need to install generator-loopback as that's the piece was broken.
He good morning Gunjpan thank you. Do you know when the fix will make its way I I the npm registry?
@subchal: I don't have any fix timeline when it will be released, but it will be released soon as it's impacting wider audience. Keep tracking this issue and #2292 as well.
@subchal: Closing this issue now as its a duplicate of #2292, please track the progress there. Thank you.