mongodb - 选定查询的猫鼬 $substr 部分
问题描述
我正在使用 Mongoose 来检索一些数据。我有一个填充集合的功能。我使用 select 从数据库中获取特定部分。
我选择了“文本”字段,但我只想检索文本的子字符串。我怎样才能做到这一点。
这是功能:
.exec(function(err, sub_docs){
subcollection.find({_id: id})
.populate({path: 'messages', select: 'title date url type text'})
.lean().exec(function(err, messages) {
res.render(main_item, {sub:sub_docs, messages: messages});
});
});
解决方案
推荐阅读
- c# - 雪花数据库:在 COPY INTO 语句中使用 VALIDATION_MODE 从外部阶段加载 JSON 文件
- ruby-on-rails - 生成新版本的 all.js 以反映 application.js 的变化:Rails 3.2.12 如何编译 all.js?
- json - 如何使用“require”在 NestJS 控制器中导入 JSON?
- javascript - 为什么这等待返回未定义?
- sql - BigQuery 将 JSON 文本展平为结构/记录数组
- spring-boot - 如何禁用 Netty HTTP 客户端连接池?
- ios - 为什么编译器声称 CGRect 没有宽度成员?
- python - Python ModuleNotFound urllib2
- javascript - 如何处理 node.js puppeteer 中的页面崩溃异常?
- python - 使用 beautifulsoup 从 wikipedia 中抓取整个表格,然后加载到 pandas