• Tools
  • Articles
  • Q&A
  • Login
0 0

mongoose 查询表中字段为数组,获取这个数组长度大于1的数据


假设存入mongo里面的数据是这样的
{
"a": 1,
"b": 2,
"c": [
"22",
"33",
"44"
]
}

查询条件:类似于{a:1}

node.js mongoose mongodb

10 years, 9 months ago
Chloe

Chloe


share
Chloe 10 years, 9 months ago

Answers

0

 db.find({'c.1': {$exists: true}})

answered 10 years, 9 months ago
Chloe

宇智波二助喵


share
宇智波二助喵 answered 10 years, 9 months ago

Your Answer

Ask Question
Related questions

mongoose如何进行高维度查询?

使用Mongoose定义的Schema包含数组,保存的时候出错CastError: Cast ...

mongoose如何取得全部结果数量并只提取部分结果

如何搭建一个垂直化的搜索引擎?(mongodb,elasticsearch)

Node.js + Mongoose 让 Model.find 方法同步执行

mongoose中$in的查询问题