So, I this nested object
Business
-- Address
---- Pincode
So, for address I am sending the {...} body and as Pincode data base is pre-populated so, I am pne sending [...] pincode id in list.
{
...
address: [
{
...
pincode: [
"Pincode Document-Id"
]
}
]
}
should this work? or does it only one layer of linking supported if so, then I would change my approach
This should be supported π§ 3 levels
mm, let me once check the exact json body that is getting send paste here
{
"businessName": "x x Store",
"ownerName": "xxxxx",
"phoneNumberLink": {
"primaryNumber": "xxxxxxx",
"$permissions": []
},
"addressLink": {
"locality": "xx",
"pincodeLink": [
"6453e9a738db8798e1f5 ],
"$permissions": []
}
}
it seems valid to me at first glance
the double quotes on pincodeLink don't look right
also make sure you have access to that document
oh right π
ahh yaap, that actully had made it read for all user
{
"businessName": "test",
"ownerName": "Harshit Kumar",
"phoneNumberLink": {
"primaryNumber": "xxxxxxxx",
"$permissions": []
},
"addressLink": {
"locality": "Kanti",
"pincodeLink": [
"6453e9a738db8798e1f5"
],
"$permissions": []
},
"businessTeamLink": [
"645b620f9fca359ca91c"
]
}
I just checked the json again couple times, yestarday actually I made mistaking pasting here.. but agai as I check today json seems valid... still it is not getting linked
I didn't understand the problem you're facing. Can you explain more please?
@safwan actully this one..
actully even first layer of linking does not work if you sending ids [...] in that format
π
what do you mean by linking? are you using relations, or manually sending the data
It should..i just tested it and the console does this too...
{
"$permissions": [
"read(\"user:6452e7df246ce0b0587b\")",
"update(\"user:6452e7df246ce0b0587b\")",
"delete(\"user:6452e7df246ce0b0587b\")"
],
"level2": [
"level2"
]
}
umm, very wired I wonder what is that I m doing wrong which is causing this ....
btw I am on 1.3.4
Can you share the response from the list collections API call from the console? This way we can see all the attributes of the two collections
yaa sure, you mean when you refresh the page during that time those response body that is visible in network tab ?
{
"$id":"64534af3c51c6287d5e3",
"$createdAt":"2023-05-07T19:52:02.622+00:00",
"$updatedAt":"2023-05-08T06:10:36.679+00:00",
"$permissions":[
"create(\"users\")",
"read(\"users\")",
"update(\"users\")"
],
"databaseId":"6451d90b58e5630094e5",
"name":"business",
"enabled":true,
"documentSecurity":false,
"attributes":[
{
"key":"businessName",
"type":"string",
"status":"available",
"required":true,
"array":false,
"size":50,
"default":null
},
{
"key":"ownerName",
"type":"string",
"status":"available",
"required":true,
"array":false,
"size":100,
"default":null
},
{
"key":"addressLink",
"type":"relationship",
"status":"available",
"required":false,
"array":false,
"relatedCollection":"64534dd42061cb7ff1f5",
"relationType":"oneToOne",
"twoWay":false,
"twoWayKey":"64534af3c51c6287d5e3",
"onDelete":"cascade",
"side":"parent"
},
{
"key":"phoneNumberLink",
"type":"relationship",
"status":"available",
"required":false,
"array":false,
"relatedCollection":"64589deed43114bb68c2",
"relationType":"oneToOne",
"twoWay":false,
"twoWayKey":"64534af3c51c6287d5e3",
"onDelete":"cascade",
"side":"parent"
},
{
"key":"businessTeamLink",
"type":"string",
"status":"available",
"required":true,
"array":false,
"size":30,
"default":null
}
],
"indexes":[
]
}```
so this for business collection...
{
"$id":"64534dd42061cb7ff1f5",
"$createdAt":"2023-05-07T19:47:35.766+00:00",
"$updatedAt":"2023-05-07T19:49:50.068+00:00",
"$permissions":[
"create(\"users\")",
"read(\"users\")",
"update(\"users\")"
],
"databaseId":"6451d90b58e5630094e5",
"name":"address",
"enabled":true,
"documentSecurity":false,
"attributes":[
{
"key":"locality",
"type":"string",
"status":"available",
"required":true,
"array":false,
"size":200,
"default":null
},
{
"key":"pincodeLink",
"type":"relationship",
"status":"available",
"required":false,
"array":false,
"relatedCollection":"6453e48c14b3f046739b",
"relationType":"manyToOne",
"twoWay":false,
"twoWayKey":"64534dd42061cb7ff1f5",
"onDelete":"restrict",
"side":"parent"
}
],
"indexes":[
]
}```
this is address json ( in this when trying to link pincode it is not getting linked
ah sending as child and expected to be created and also get linked
if it's a many to one, you should be passing a single ID only rather than an array
Recommended threads
- Relations within the same table
Hello, I'm currently building a sort of dictionary (a literal one) and thus I need words (which is one single table of words in my database) to be able to have ...
- [SOLVED] Query.search() returning all ro...
When I use Query.search() instead of returning rows with the keywords provided it just returns all the rows in the table.
- 1:1 relationship doesnβt sync after re-a...
Hi, Iβm trying to use a two-way one-to-one relationship. It works fine when I create a record with the relationship set, and it also works when I unset it. But ...