本文介绍了水线,在阵列中找到数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有视频模型:

module.exports = {

  attributes: {
    id: 'string',
    tags: 'array'
  },
}

我想找到所有带有标签的视频,例如Hello或World。
我可以轻松获得所有视频:
Video.find({tags:Hello})。我看到了搜索id:[1,2,3]的示例,但是当key(id => tags)是数组时没有。

I want to find all videos with tags for example "Hello" or "World".I could easy get all videos like:Video.find({tags:"Hello"}). I saw examples where searching id: [1,2,3] but not when key(id => tags) is array.

推荐答案

Video.find({tags: {"$in" : ["sometag1", "sometag2"]}})

这允许我在数组中找到数组

this allows me find array in array

这篇关于水线,在阵列中找到数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 18:41
查看更多