Uploaded image for project: 'PHP ORMs'
  1. PHP ORMs
  2. PHPORM-236

Remove _id from result for query builder

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • laravel-5.0.0
    • Affects Version/s: None
    • Component/s: Laravel
    • None
    • PHP Drivers
    • Needed
    • Hide

      If not already documented, show that when the document contains an _id field in database, it is renamed to "id" in the result object.

      Warning: this also impacts the "$group" stage that must contain an "_id".

      Show
      If not already documented, show that when the document contains an _id field in database, it is renamed to "id" in the result object. Warning: this also impacts the "$group" stage that must contain an "_id".

      After PHPORM-147, we encourage the use of “id” instead of “_id” for cross-compatibility with Laravel SQL Query Builder. Currently, the query builder returns "_id" and "id" when "_id" is is the result data. This can be confusing when you don't know which field to use.
      Removing "_id" avoids ambiguity and maintains compatibility with Laravel.

       

      Also, when the result document is used as input for insert/update, this prevent having duplicate fields. https://github.com/mongodb/laravel-mongodb/pull/3040#issuecomment-2330222281

            Assignee:
            jerome.tamarelle@mongodb.com Jérôme Tamarelle
            Reporter:
            jerome.tamarelle@mongodb.com Jérôme Tamarelle
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: