ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、视频、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
## 1.正则查询 ~~~ const MongoClient = require('mongodb').MongoClient; var url = 'mongodb://localhost:27017/'; MongoClient.connect(url, { useNewUrlParser: true }, (err, client) => { if (err) throw err; var test = client.db('test'); test.collection('douban').find({address:/^l/}).toArray((err, result) => { if (err) throw err; console.log(result); client.close(); }) }) ~~~ ## 2.查询特定的属性 ~~~ const MongoClient = require('mongodb').MongoClient; var url = 'mongodb://localhost:27017/'; MongoClient.connect(url, { useNewUrlParser: true }, (err, client) => { if (err) throw err; var test = client.db('test'); test.collection('douban').find({age:30).toArray((err, result) => { if (err) throw err; console.log(result); client.close(); }) }) ~~~