对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

查找多个文档

您可以使用 Model::where() 等方法或 DB 门面中的方法匹配文档,然后调用 get() 方法检索结果,从而从集合中检索多个文档。

Pass a query filter to the where() method to retrieve documents that meet a set of criteria. When you call the get() method, MongoDB returns the matching documents according to their natural order in the collection or according to the sort order that you can specify by using the orderBy() method.

提示

要学习;了解使用 Laravel 集成检索文档的其他方法,请参阅读取操作指南。

从以下 Eloquent 和 Query Builder 标签页中选择,查看使用每个相应查询语法的同一操作的用法示例:

此示例将执行以下动作:

  • 使用Movie Eloquent 模型表示sample_mflix数据库中的movies集合

  • 从movies集合中检索并打印与查询筛选器匹配的文档

该示例在Movie模型上调用以下方法:

  • where():匹配 runtime字段的值大于 900 的文档

  • orderBy():按 _id 值升序对匹配的文档进行排序

  • get():以 Laravel集合对象的形式检索查询结果

$movies = Movie::where('runtime', '>', 900)
->orderBy('_id')
->get();

要了解如何编辑 Laravel 应用程序以运行用法示例,请参阅用法示例登录页面。

给本页内容打分

在此页面上