| 178 | > |
| 179 | |
| 180 | export function templateSelection( |
| 181 | eb: ExpressionBuilder<DB, 'note' | 'card' | 'template'>, |
| 182 | ) { |
| 183 | return [ |
| 184 | 'template.ankiId as template_ankiId', |
| 185 | 'template.created as template_created', |
| 186 | 'template.css as template_css', |
| 187 | 'template.fields as template_fields', |
| 188 | 'template.id as template_id', |
| 189 | 'template.edited as template_edited', |
| 190 | 'template.name as template_name', |
| 191 | 'template.templateType as template_templateType', |
| 192 | |
| 193 | jsonArrayFrom( |
| 194 | eb |
| 195 | .selectFrom('remoteTemplate') |
| 196 | .select(['uploadDate', 'nook', 'remoteId']) |
| 197 | .whereRef('note.templateId', '=', 'remoteTemplate.localId'), |
| 198 | ).as( |
| 199 | 'remoteTemplate', |
| 200 | ) satisfies RemoteTemplateJsonArray as RemoteTemplateJsonArray, |
| 201 | ] as const |
| 202 | } |
| 203 | |
| 204 | type TemplatePrefix<T> = { |
| 205 | [P in keyof T as `template_${string & P}`]: T[P] |