mongodb / laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)
https://www.mongodb.com/docs/drivers/php/laravel-mongodb/
MIT License
7.01k stars 1.43k forks source link

[Feature Request] Options to ignore auto conversion id to _id #3184

Open kbiits opened 6 days ago

kbiits commented 6 days ago

Is your feature request related to a problem?

We have a merchant.id field in our mongodb document, and after upgrading to mongodb driver 5.1 we encountered issue that mongodb driver modify the where query from merchant.id to merchant._id which results to unexpected query

Describe the solution you'd like

It would be good if there's mechanism to whitelisting the fields from auto conversion .id to ._id

Describe alternatives you've considered

-

Additional context

This part of code modify all .id to ._id

image
Abdullahbutt3434 commented 5 days ago

I am looking for the solution here

Abdullahbutt3434 commented 5 days ago
**protected $primaryKey = '_id';**
I tried to put above line in model that is not working as well
if we want to go with _id there must a be 
please guide. 
kbiits commented 5 days ago

I am looking for the solution here

What I've done to get rid of the issue is by downgrading the MongoDB driver to version 4.x