小编slo*_*p02的帖子

通过搜索嵌套对象属性来过滤对象数组

我有一个对象数组,我想通过将嵌套属性与搜索词进行比较来进行过滤。

例如:

 var array = [
      {category: 'Business'
       users: [
                {name: 'Sally'
                 tags: [{tag: 'accounting'}, {tag: 'marketing'},...]
                },
                {name: 'Bob'
                 tags: [{tag: 'sales'}, {tag: 'accounting'},...]
                }...
              ]
       },
       {category: 'Heritage'
        users: [
                 {name: 'Linda'
                  tags: [{tag: 'Italy'}, {tag: 'Macedonia'},...]
                 },
                 {name: 'George'
                  tags: [{tag: 'South Africa'}, {tag: 'Chile'},...]
                 },...
               ]
       },...
    [
Run Code Online (Sandbox Code Playgroud)

本质上,我想通过一个搜索词来过滤对象的基本数组,这些搜索词包括嵌套2个数组以下的对象的tag属性字符串中的字符。

因此,搜索“市场”将导致

[
  {category: 'Business'
   users: [
            {name: 'Sally'
             tags: [{tag: 'accounting'}, {tag: 'marketing'},...]
            },
            {name: 'Bob'
             tags: [{tag: 'sales'}, {tag: 'accounting'},...]
            }...
          ]
   }
]
Run Code Online (Sandbox Code Playgroud)

谢谢。

javascript arrays object filter

6
推荐指数
1
解决办法
5245
查看次数

AWS Cloudfront CacheBehavior PathPattern 中可接受的通配符

尝试在我们的应用程序中设置路径的缓存行为时,AWS 文档仅显示尾随通配符的示例(/images/*https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudfront-distribution- cachebehavior.html#cfn-cloudfront-distribution-cachebehavior-pathpattern,以及https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesPathPattern)。

然而,我们使用在路径的其余部分之前实现语言变量的路径模式,例如(/{language}/product/{productId})。

在云形成模板中,在每个变量点中设置带有通配符的 PathPattern 是否可以接受?

IE /*/product/*

如果没有,我用/product/*我相信只有像这样的路线https://website.com/product/{productId}才会被cloudfront拾取来分析,并且像这样的路线https://website.com/en/product/{productId}将会被错过。

browser-cache amazon-web-services amazon-cloudfront

6
推荐指数
1
解决办法
3563
查看次数

使用 Slack 登录 - 无效范围:identity.basic、identity.avatar

我已经使用 Oauth2.0 成功调用安装了我的 slack 应用程序

https://slack.com/oauth/v2/authorize?client_id=<myAppsClientId>&scope=chat:write,commands,incoming-webhook,users:read&user_scope=chat:write,users:read
Run Code Online (Sandbox Code Playgroud)

但是当我尝试使用 Slack 登录时(因此用户可以在我的网络应用程序上管理他们的 slack)我使用

https://slack.com/oauth/v2/authorize?scope=identity.basic,identity.avatar&client_id=<myAppsClientId>
Run Code Online (Sandbox Code Playgroud)

用户在 slack url 上收到错误(在重定向到我的应用程序之前):

Error details
  Invalid permissions requested
  Invalid scopes: identity.basic, identity.avatar
Run Code Online (Sandbox Code Playgroud)

由于添加到 slack 和使用 slack 登录都调用相同的 uri,因此我假设范围参数是将两者分开的。不确定我哪里出错了,因为我遵循了文档并使用了他们为我生成的按钮。

oauth-2.0 slack-api slack

4
推荐指数
2
解决办法
1353
查看次数