//native
type Xata = {
apiKey: string
}
/**
* Update Database metadata
* Update the color of the selected database
*/
export async function main(
auth: Xata,
workspace_id: string,
db_name: string,
body: { ui?: { color?: string } }
) {
const url = new URL(`https://api.xata.io/workspaces/${workspace_id}/dbs/${db_name}`)
const response = await fetch(url, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + auth.apiKey
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 428 days ago