我在NextJs 13应用程序中有以下模型。我正在使用grafbase。
// @ts-ignore
const User = g
.model('User', {
name: g.string().length({ min: 2, max: 100
}).optional(),
email: g.string().unique(),
password: g.string().optional(),
active: g.boolean().optional(),
allowReset: g.boolean().optional(),
avatarUrl: g.url().optional(),
})
.auth((rules) => {
rules.public().read()
rules.private().create().delete().update()
})
// @ts-ignore
const ActivateToken = g
.model('ActivateToken', {
token: g.string().unique(),
activatedAt: g.datetime().optional(),
createdBy: g.relation(() => User),
})
.auth((rules) => {
rules.public().read()
rules.private().create().delete().update()
})
在创建用户并从我发送的电子邮件中激活后,更新活动状态,一切正常。
如果我删除ActivateToken,该用户将不再显示在ActiveTokenCollection中,但该用户仍在数据库中,就像我按显示的id搜索用户一样。非常奇怪的问题。
如果我不删除令牌,一切都很好,但考虑到维护和没有大量令牌,我考虑过删除旧的、过期的令牌。
有什么想法吗?