【问题标题】:Google Calendar API conditionals谷歌日历 API 条件
【发布时间】:2020-10-20 03:04:41
【问题描述】:

我正在尝试在事件列表查询上构建条件,但在此示例中找不到用于指定 OR 条件的文档:

gapi.client.calendar.events.list({
            'calendarId': 'primary',
            //'timeMin': from_datetime,     // pick everything since we already search by sharedExtendedProperty
            'showDeleted': false,
            'singleEvents': true,
            'maxResults': 100,
            'orderBy': 'startTime',
            **'sharedExtendedProperty': ['createdBy=someapp-alpha', 'createdBy=someapp-beta', 'createdBy=someapp-prod']**
        }).then(
            function (res) {

我希望能够使用 sharedExtendedProperty x OR sharedExtendedProperty y OR sharedExtendedProperty z 查询内容... 将这 3 种可能性都添加到数组中没有结果。所以我猜它是在做一些 AND 而不是 OR。那么,有什么线索吗????

谢谢!

【问题讨论】:

  • 如果你找不到任何关于它的文档,你怎么知道它支持?
  • 我实际上不知道,但如果不支持它似乎很奇怪......文档说“扩展属性约束指定为 propertyName=value。仅匹配共享属性。此参数可能会重复多次返回匹配所有给定约束的事件。” ...我想这意味着支持 AND 吗?那为什么不支持OR呢?

标签: javascript google-api google-calendar-api google-api-js-client


【解决方案1】:

无法将OR 查询合并到calendar.events.list 扩展属性请求中

您需要手动操作

  • 首先提出 3 个单独的列表请求
  • 随后以编程方式合并结果

【讨论】:

  • 有没有办法使用通配符或正则表达式?我所有的扩展属性都以 -beta 为后缀;我可以只查询 'sharedExtendedProperty': 'createdBy=*-beta' 或类似的东西吗?
  • 很遗憾没有。此外,您可以从documentation 中提取qFree text search terms to find events that match these terms in any field, except for extended properties.。您可以在Google Issue Tracker 提出功能请求以实现更好的查询功能,也许最终会被合并。
  • 这是一种执行多个请求的优雅而高效的方式!
猜你喜欢
  • 2016-04-15
  • 1970-01-01
  • 1970-01-01
  • 2016-01-03
  • 2017-08-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多