0

我有当前的表:

create table Tokens (
  token varchar(256) not null,
  duser varchar(32) not null,
  type varchar(16) not null,
  expires_in datetime not null,
  auth_time datetime not null,

  primary key(token),
  foreign key(duser) references User(id)
);

我想在下面进行查询:

select * from Tokens where duser = "myid" and expires_in > current_timestamp
--or something to compare if expires_in is greater than the current date **and** time

但我正在使用Exposed。我已经做了这个:

return transaction {
            Database.TOKENS.run {
                select {
                    (user eq this@DogoUser.id) and (expiresIn greater) //stopped here
                }
            }
        }

如何通过current_timestampJetbrains Exposed 引用 MySQL 变量?

4

1 回答 1

2

Exposed 中有 CurrentDateTime 表达式。

select {
   (user eq this@DogoUser.id) and (expiresIn.greater(CurrentDateTime()) 
}
于 2019-02-10T18:53:12.230 回答