issue_comments: 1302721916
This data as json
html_url | issue_url | id | node_id | user | created_at | updated_at | author_association | body | reactions | issue | performed_via_github_app |
---|---|---|---|---|---|---|---|---|---|---|---|
https://github.com/simonw/datasette/issues/1882#issuecomment-1302721916 | https://api.github.com/repos/simonw/datasette/issues/1882 | 1302721916 | IC_kwDOBm6k_c5NpfV8 | 9599 | 2022-11-03T21:58:50Z | 2022-11-03T21:59:17Z | OWNER | Mocked up a quick HTML+JavaScript form for creating that JSON structure using some iteration against Copilot prompts: ```html <pre> /* JSON format: { "table": { "name": "my new table", "columns": [ { "name": "id", "type": "integer" }, { "name": "title", "type": "text" } ] "pk": "id" } } HTML form with Javascript for creating this JSON: */</pre> <form id="create-table-form"> <label for="table-name">Table name</label> <input type="text" id="table-name" name="table-name" required><br> <label for="table-pk">Primary key</label> <input type="text" id="table-pk" name="table-pk" required><br> <label for="column-name">Column name</label> <input type="text" id="column-name" name="column-name" required> <label for="column-type">Column type</label> <input type="text" id="column-type" name="column-type" required> <button type="button" id="add-column">Add column</button> <p>Current columns:</p> <ul id="columns"></ul> <button type="button" id="create-table">Create table</button> </form> <script> var form = document.getElementById('create-table-form'); var tableName = document.getElementById('table-name'); var tablePk = document.getElementById('table-pk'); var columnName = document.getElementById('column-name'); var columnType = document.getElementById('column-type'); var addColumn = document.getElementById('add-column'); var createTable = document.getElementById('create-table'); var columns = []; addColumn.addEventListener('click', () => { columns.push({ name: columnName.value, type: columnType.value }); var li = document.createElement('li'); li.textContent = columnName.value + ' (' + columnType.value + ')'; // Add a delete button to each column var deleteButton = document.createElement('button'); deleteButton.textContent = 'Delete'; deleteButton.addEventListener('click', () => { columns.splice(columns.indexOf(li), 1); li.remove(); }); li.appendChild(deleteButton); document.getElementById('columns').appendChild(li); }); createTable.addEventListener('click', () => { var table = { name: tableName.value, pk: tablePk.value, columns: columns }; console.log(JSON.stringify(table, null, 2)); }); </script> ``` | {"total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0} | 1435294468 |