Sails-mongo.在数组中查找 [英] Sails-mongo. Find in array

查看:122
本文介绍了Sails-mongo.在数组中查找的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用sails.js和sails-mongo适配器.假设我有一个模型:

I'm using sails.js and sails-mongo adapter. Suppose I have a model:

module.exports = {

  attributes: {

        shema: true
    ,   attributes: {
                description: {
                    type: 'TEXT'
                ,   max: 200
            }

            ,   tags: {
                    type: 'ARRAY'
            }
    }

  }

};

如何在标签数组中进行搜索?

How can I carry out a search in an tags array?

推荐答案

Model.find({
    'tags.title': {
        contains: 'query'
      }
})
.done(function (err, response) {
    /**/
});

这篇关于Sails-mongo.在数组中查找的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆