【问题标题】:How to get users having birthday today in loopback?如何让用户今天在环回中过生日?
【发布时间】:2022-01-25 15:47:46
【问题描述】:

我需要在我的应用程序中向用户发送生日祝福。

我有一个表“userdetails”,其中包含“dob”列。我需要一个查询来检索出生日期与今天匹配的用户。

例如,如果用户的“dob”值为“1991-01-21 00:00:00”,我必须向该用户发送生日电子邮件。

const users = await userdetails.find({
 where: {
   dob: "  " // not sure what goes in there
 },
});

在这里,我不确定我可以在 where 字段中输入什么来匹配我的查询。

【问题讨论】:

标签: javascript node.js loopbackjs loopback


【解决方案1】:

如果列类型为date,代码大概是这样的:

where: {
    dob: new Date().toISOString().slice(0,10), // '2022-01-25'
},

【讨论】:

    猜你喜欢
    • 2018-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多