Node.js 航行在蒙哥。在数组中查找

Node.js 航行在蒙哥。在数组中查找,node.js,mongodb,express,sails.js,Node.js,Mongodb,Express,Sails.js,我正在使用sails.js和sails-mongo适配器。假设我有一个模型: module.exports = { attributes: { shema: true , attributes: { description: { type: 'TEXT' , max: 200 } , tags: {

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

module.exports = {

  attributes: {

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

            ,   tags: {
                    type: 'ARRAY'
            }
    }

  }

};
如何在标记数组中执行搜索

Model.find({
    'tags.title': {
        contains: 'query'
      }
})
.done(function (err, response) {
    /**/
});
这里有一个很好的例子:

有吃水线

Model.native(function(err, collection) {
    // Execute any query that works with the mongo js driver
    collection.find( { criteria },
                 { atributes: { $elemMatch: { tags: value } } } )
    });

看看代码,它运行mongo的$regex,这很昂贵。似乎不存在对mongo实际阵列操作的支持。您的答案显示了如何通过mongo cli执行此搜索。问题是如何通过waterline.js实现搜索
Model.native(function(err, collection) {
    // Execute any query that works with the mongo js driver
    collection.find( { criteria },
                 { atributes: { $elemMatch: { tags: value } } } )
    });