user-login-history.prisma 784 B

1234567891011121314151617181920212223
  1. model UserLoginHistory {
  2. id String @id @map("_id") @default(auto()) @db.ObjectId
  3. uid String // 设备码
  4. ip String // 登录 IP
  5. userAgent String? // UA (optional but useful)
  6. appVersion String? // 客户端版本 (optional)
  7. os String? // iOS / Android / Browser
  8. createAt BigInt // 登录时间 (epoch)
  9. // Queries you will use a lot:
  10. // 1. 查某设备所有登录记录
  11. @@index([uid, createAt])
  12. // 2. 查某 IP 的登陆情况(反刷)
  13. @@index([ip, createAt])
  14. // 3. 全局统计(按时间分片)
  15. @@index([createAt])
  16. @@map("userLoginHistory")
  17. }