首页 > 解决方案 > 选定查询的猫鼬 $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});
        });
      });

标签: mongodbselectmongoosepopulate

解决方案


推荐阅读