jsforce 查询方法链以查找 2 个日期之间的数据 [英] jsforce query method chain to find data between 2 dates

查看:63
本文介绍了jsforce 查询方法链以查找 2 个日期之间的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了 SOQL 查询来获取 2020-06-01 和 2020-06-30 两个日期之间的数据

I have written SOQL query to get the data between 2 dates 2020-06-01 and 2020-06-30

SELECT Id ,LastModifiedDate
FROM Account  
WHERE LastModifiedDate >= 2020-06-01T00:00:00Z
AND LastModifiedDate <= 2020-06-30T23:59:59Z

但我想使用方法链来实现它

but I want to implement it using method chain

推荐答案

见这个 link 有关如何将 SF 日期的字符串表示形式转换为日期文字的信息.

See this link for information on how to convert a string representation of a SF date to a date literal.

其余的只是根据您的查询对官方文档的修改.

The rest is just a modification for the official docs per your query.

(async _ => {
    const results = await conn.sobject("Account")
          .find(
            // conditions in JSON object
            { 
              LastModifiedDate : { $gte : jsforce.SfDate.toDateTimeLiteral('2020-06-01T00:00:00Z'), $gte : jsforce.SfDate.toDateTimeLiteral('2020-06-30T23:59:59Z') },
            },
            // fields in JSON object
            { 
              Id: 1,
              LastModifiedDate: 1
            }
          ) // end method chain
          console.log(results)
})()

这篇关于jsforce 查询方法链以查找 2 个日期之间的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆