I have 2 collection productContent and skills, Both the collection have relationship attribute of each other. I want productContent should contain array of skill's id and skills collection should contain array of product id's. for productContent its working fine, it storing array of skills id, but skills collection is adding redundant data. I am using 2 way many to many relationship
Where are the redundant data? Do you mean the item[1] that's displayed? If so I don't think it's redundant data that's just how relationship data is displayed sometimes. To make sure though, check the details of each record and verify that it's indeed redundant data.
no i don't want technology to have repeated values
technology => [list of product id's]
as these productContent have stored the value.
Do you mean you don’t want it to be possible to add multiple records to Skills with the same technology field? So in your example screenshot, you have two reacts records?
yes
You can create an Index with a type of “Unique”, and select “technology” for the Attribute. Then, attempting to create a new Document with the same technology as one already there will fail
oh got it, i will try it
it wont even adding value in productContent by this.
Not sure what you mean by this?
i have 2 collections productContent and skills. productContent has relationship attribute with skills collections, it store skills => [list of skills id's] (this was working fine, it was adding the skills id's from skills collection). skills collection also have relationship attribute with productContent collections, it should store productContent => [list of project id's], its not storing the unique technology, technology are getting repeated in the collections. As you suggested to include Index with unique type, I did that, now if the project is having any existing skills/technology, it neither adding in productContent collection nor in skills collection. I just want to do, in productContent collection should have relationship attribute with skills collection and will store skills id (skills=>[skillId1, skillId2...] and skills collection should have relationship attribute with productContent collection and store product id (productContent => [productid1, productId 2...]
Like this in productContent {
"title": "Product Title",
"profileImage": "image_url.jpg",
"uploadDate": "2023-01-01",
"updateDate": "2023-12-25",
"skills": [
"skillId1",
"skillId2",
"skillId3"
]
}
In skills collection {
"skillId1": {
"technology": "Technology 1"
"productContent": ["productId1", "productId2"]
},
"skillId2": {
"technology": "Technology 2"
"productContent": ["productId2", "productId3"]
},
...
}
Recommended threads
- Weird permission failure
when creating an account I use following methods: ``` Future<void> register(String email, String password, String username) async { final user = await accoun...
- Paused project can't activate
I have failed to reactivate one my projects which had been paused
- Site deployment keeps getting failed
Hi good folks, need a hand with Sites deploy Error on every deploy: Synchronous function execution timed out... duration doesn't exceed 30 seconds [exact log ...