Find by exact id, id prefix (>=4 chars), or exact name.
(idOrName: string)
| 141 | |
| 142 | /** Find by exact id, id prefix (>=4 chars), or exact name. */ |
| 143 | resolve(idOrName: string): ScheduleEntry | undefined { |
| 144 | const exact = this.get(idOrName); |
| 145 | if (exact) return exact; |
| 146 | const byName = this.db.prepare(`SELECT * FROM schedules WHERE name = ?`).get(idOrName) as ScheduleEntry | undefined; |
| 147 | if (byName) return byName; |
| 148 | if (idOrName.length >= 4) { |
| 149 | const matches = this.db.prepare(`SELECT * FROM schedules WHERE id LIKE ?`).all(`${idOrName}%`) as ScheduleEntry[]; |
| 150 | if (matches.length === 1) return matches[0]; |
| 151 | } |
| 152 | return undefined; |
| 153 | } |
| 154 | |
| 155 | list(): ScheduleEntry[] { |
| 156 | return this.db.prepare(`SELECT * FROM schedules ORDER BY created_at ASC`).all() as ScheduleEntry[]; |
no test coverage detected