A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.mongodb.com/docs/drivers/php/laravel-mongodb/current/usage-examples/deleteOne/ below:

Delete a Document - Laravel MongoDB

You can delete a document in a collection by retrieving a single Eloquent model and calling the delete() method, or by calling delete() directly on a query builder.

To delete a document, pass a query filter to the where() method, sort the matching documents, and call the limit() method to retrieve only the first document. Then, delete this matching document by calling the delete() method.

Tip

To learn more about deleting documents with the Laravel Integration, see the Delete Documents section of the Write Operations guide.

Select from the following Eloquent and Query Builder tabs to view usage examples for the same operation that use each corresponding query syntax:

This example performs the following actions:

The example calls the following methods on the Movie model:

$deleted = Movie::where('title', 'Quiz Show')    ->limit(1)    ->delete();echo 'Deleted documents: ' . $deleted;

This example performs the following actions:

The example calls the following query builder methods:

$deleted = DB::table('movies')    ->where('title', 'Quiz Show')    ->limit(1)    ->delete();echo 'Deleted documents: ' . $deleted;

To learn how to edit your Laravel application to run the usage example, see the Usage Examples landing page.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4