Open
Description
I have 2 Models Product
& Size
. They are ManyToMany
related to each other.
Now, every Product
will have different price with respect to the Size
.
It is simple in Laravel:
$product->sizes()->sync(['foriegnKey' => ['price' => 200]])
// Here foriegnKey will be an integer for MySQL in default setup unless using UUID.
// I am doing the similar thing here with this package
$product->sizes()->sync(['sizeObjectId' => ['price' => 200]])
But this is not working. This is an URGENT FIX in my opinion. Because it is not working as it should be.
If you don't want to make use of Pivot Collection
then you can put the IDS in an Object
instead of an array. The object will be a Key-Value pair having the Object ID as key and the value being another Object with the Pivot Attributes.
Tell me, if I am approaching this scenario differently / wrongly than how MongoDB works. Is there any better solution to this scenario in MongoDB?