8000 The withPivot fields are getting ignored. · Issue #1618 · mongodb/laravel-mongodb · GitHub
[go: up one dir, main page]

Skip to content
The withPivot fields are getting ignored. #1618
Open
@tzsk

Description

@tzsk

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0