Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有这样的收藏:
{ "city" : "ACMARE", "state" : "AL", "_id" : "001" }
如何使用正则表达式按城市聚合此集合?例如:名称以字母 from Dto开头的城市H?我读了这个,但仍然不清楚如何使用正则表达式。
D
H
试试这个:
db.collection.aggregate( { $match: { city : /^[D-H].*/ } } );
db.Collection.find( { city: /^[D-H]/ } )