feat: add candidate SQL table presets and script-building composable
This commit is contained in:
15
src/composables/sqlTable.ts
Normal file
15
src/composables/sqlTable.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { ref } from "vue"
|
||||
import { defaultSqlTableId, sqlTables } from "../data/sqlTables"
|
||||
|
||||
export const selectedTableId = ref(defaultSqlTableId)
|
||||
|
||||
export function resetSqlTableSelection() {
|
||||
selectedTableId.value = defaultSqlTableId
|
||||
}
|
||||
|
||||
export function buildSqlScript(studentSql: string) {
|
||||
const table =
|
||||
sqlTables.find((item) => item.id === selectedTableId.value) ??
|
||||
sqlTables[0]
|
||||
return `${table.setupSql}\n\n${studentSql}\n\nSELECT * FROM ${table.tableName};`
|
||||
}
|
||||
Reference in New Issue
Block a user