Skip to content

v5.0.2

Choose a tag to compare

@pdphilip pdphilip released this 28 Mar 16:02
· 62 commits to main since this release

This release is compatible with Laravel 10, 11 & 12

What's changed

1. New feature, bulkInsert()

bulkInsert() is identical to insert() but will continue on errors and return an array of the results.

People::bulkInsert([
    [
        'id' => '_edo3ZUBnJmuNNwymfhJ', // Will update (if id exists)
        'name' => 'Jane Doe',
        'status' => 1,
    ],
    [
        'name' => 'John Doe',  // Will Create
        'status' => 2,
    ],
    [
        'name' => 'John Dope',
        'status' => 3,
        'created_at' => 'xxxxxx', // Will fail
    ],
]);

Returns:

{
    "hasErrors": true,
    "total": 3,
    "took": 0,
    "success": 2,
    "created": 1,
    "modified": 1,
    "failed": 1,
    "errors": [
        {
            "id": "Y-dp3ZUBnJmuNNwy7vkF",
            "type": "document_parsing_exception",
            "reason": "[1:45] failed to parse field [created_at] of type [date] in document with id 'Y-dp3ZUBnJmuNNwy7vkF'. Preview of field's value: 'xxxxxx'"
        }
    ]
}

2. Bug fix: distinct() aggregation now appends searchAfter key in meta

Full Changelog: v5.0.1...v5.0.2