0

私は Sails.js と Sails-mongo アダプターを使用しています。モデルがあるとします:

module.exports = {

  attributes: {

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

            ,   tags: {
                    type: 'ARRAY'
            }
    }

  }

};

タグ配列で検索を実行するにはどうすればよいですか?

4

2 に答える 2

-1
db.schools.find( { criteria },
             { atributes: { $elemMatch: { tags: value } } } )

ここに素晴らしい例があります: http://docs.mongodb.org/manual/reference/operator/projection/elemMatch/

水線付き

Model.native(function(err, collection) {
    // Execute any query that works with the mongo js driver
    collection.find( { criteria },
                 { atributes: { $elemMatch: { tags: value } } } )
    });
于 2015-08-13T22:36:12.427 に答える