使用mongoose查询属性名为中文,内容也为中文的数据,限制条件无效。
var mongoose = require('mongoose'); const DB_URL="mongodb://localhost:27017/中医药数据库" mongoose.connect(DB_URL) var date = new Date() const schema = mongoose.Schema(); const collection = mongoose.model('date',schema,medicinecapital); collection.findOne( { '药名': "矮脚龙胆" } ).then(function(info) { console.log(info) })

返回的结果是该集合中的第一条数据,如果使用find函数查询则返回该集合中的所有数据
请问该怎么办?
db.col.find({ '药名': "矮脚龙胆"}).pretty()
参考如下文档。
https://www.runoob.com/mongodb/mongodb-query.html
用JS的Filter 函数。
把你的数据读出来。
然后
Array.filter(item=>item["药名"]==矮脚龙胆)
实在不行,那就只能转英文列名了。