如何在 mongo dart 中搜索文档数组?

How do you search an array of documents in mongo dart?

如何使用 dart 编程语言在 mongodb 中搜索文档数组?

我正在使用 https://pub.dartlang.org/packages/mongo_dart 作为驱动程序

示例数据库集合如下所示

"name": [ {"full":"Tyler Thompson", "first":"Tyler", "last":"Thompson" } ]

使用以下查询将有助于实现您对同一个名字的目标

String search = "Tyler";

{"name.full": {'$regex': '${search}'}

希望对您有所帮助!找不到例子,所以我想我会给出一个!:)

你可以试试看https://github.com/vadimtsushko/mongo_dart/blob/master/example/queries.dart

对于您的示例,类似这样的方法似乎可行:

coll.find(where.eq('name.full','Tyler'))

或者也许

coll.find(where.match('name.full','^Tyl[eo]r'))