-
Type:
New Feature
-
Resolution: Fixed
-
Priority:
Unknown
-
Affects Version/s: None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
By convention in Eloquent, model's primary key is id. But MongoDB uses _id as primary key (unique index automatically created and can't be removed).
In order to support Laravel packages out of the box, the proposition is to modify the query builder so any query on the "id" field is converted to a query to "_id" field.
$builder->where('id', 123)
becomes
{ _id: 123 }And the same for the result. When _id is returned, the value is converted to id. This is the most tricky part as we don't want to break backward compatibility for projects that refer to _id. But this is a necessary abstraction to match Eloquent design.
Breaking change: using an "id" field distinct from "_id" would not be supported.
Related rejected PR:
- causes
-
PHPLARA-118 Rename _id to id in Schema::getColumns introspection
-
- Closed
-
- fixes
-
PHPLARA-65 laravel-mongodb - Issue #3022: [Feature Request] SessionServiceProvider for database
-
- Closed
-
- is depended on by
-
PHPLARA-143 Remove custom DatabaseTokenRepository
-
- Closed
-
-
PHPLARA-153 Remove MongoFailedJobProvider
-
- Closed
-
- is related to
-
PHPLARA-241 Remove _id from result for query builder
-
- Closed
-