Repository navigation
Description
Hello.
We are using more than one loopback project using a microservices architecture connecting with each other using loopback remote connector. Finally, the database is mongodb.
On API1, we have the supplier model and on API2 we have the KmRange method which has a hasMany relation with supplier model.
The problem is that if I call to suppliers/:id/kmRanges I obtain an empty array although I have related data. I use an special property on each model to set an id as the loopback documentation says.
This is the supplier model.json :
{
"name": "Supplier",
"plural": "Suppliers",
"base": "PersistedModel",
"idInjection": false,
"forceId": false,
"options": {
"validateUpsert": true
},
"properties": {
"id": {
"type": "string",
"generated": true,
"id": true
},
"name": {
"type": "string",
"required": true
},
"image": {
"type": "string"
},
"phone": {
"type": "string"
},
"addressLine1": {
"type": "string"
},
"addressLine2": {
"type": "string"
},
"city": {
"type": "string"
},
"region": {
"type": "string"
},
"country": {
"type": "string",
"default": "España"
},
"postalCode": {
"type": "string"
}
},
"validations": [],
"relations": {
"zones": {
"type": "hasMany",
"model": "Zone",
"foreignKey": ""
},
"rates": {
"type": "hasMany",
"model": "Rate",
"foreignKey": ""
},
"volumetricWeightRanges": {
"type": "hasMany",
"model": "VolumetricWeightRange",
"foreignKey": ""
},
"price": {
"type": "belongsTo",
"model": "price",
"foreignKey": "idSupplier"
},
"KmRange": {
"type": "hasMany",
"model": "KmRange",
"foreignKey": "idSupplier"
},
"routes": {
"type": "hasMany",
"model": "Route",
"foreignKey": "idSupplier"
},
"carrier": {
"type": "hasMany",
"model": "Carrier",
"foreignKey": "idSupplier"
}
},
"acls": [
{
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW",
"property": "*"
}
],
"methods": {}
}
And this is the kmRange model.json:
{
"name": "KmRange",
"plural": "KmRanges",
"base": "PersistedModel",
"idInjection": false,
"options": {
"validateUpsert": true
},
"properties": {
"id": {
"type": "string",
"generated": true,
"id": true
},
"min": {
"type": "number",
"required": true
},
"max": {
"type": "number",
"required": true
}
},
"validations": [],
"relations": {
"supplier": {
"type": "belongsTo",
"model": "Supplier",
"foreignKey": "idSupplier"
}
},
"acls": [
{
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW",
"property": "*"
}
],
"methods": {}
}
And finally, this a kmRange document on mongodb:
{ _id: ObjectId("590c7afd19ec56003cc97996"), min: NumberLong("100"), max: NumberLong("9999999"), supplierId: "590c7ad2beb2a70039aab8b2" }
If change on database an supplierId kmRange property to objectId, the get works:
{ _id: ObjectId("590c7afd19ec56003cc97997"), min: NumberLong("50"), max: NumberLong("100"), supplierId: ObjectId("590c7ad2beb2a70039aab8b2") }
Thanks in advance.
David
Activity
davidrivers93 commentedon May 22, 2017
Any idea?
stale commentedon Aug 23, 2017
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
stale commentedon Sep 6, 2017
This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the
CODEOWNERSfile at the top-level of this repository.