Simpler demo
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 13.7k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
The sample demo in the readme seems intimidating...
Here's a simpler one:
<head>
<title>Demo</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/sql.js/1.12.0/sql-wasm.js"></script>
<!-- preload sql-wasm.wasm, if you like -->
</head>
<body>
<button id='btn'>Run query</button>
<script type='module'>
// Initialize SQL.js
const SQL = await initSqlJs({
locateFile: () => `https://cdnjs.cloudflare.com/ajax/libs/sql.js/1.12.0/sql-wasm.wasm`
})
// Create a db with sample data
const db = new SQL.Database()
db.run(`CREATE TABLE test (id INTEGER, name TEXT); INSERT INTO test VALUES (1, 'Alice'), (2, 'Bob')`)
// Run a query
async function run() {
const result = await db.exec("SELECT * FROM test")
console.log(result[0].values)
}
btn.addEventListener('click', run)
</script>
</body>
For previous versions:
<head>
<title>Demo</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/sql.js/0.5.0/js/sql-optimized.js"></script>
</head>
<body>
<button id='btn'>Run query</button>
<script type='module'>
const db = new SQL.Database()
db.run(`CREATE TABLE test (id INTEGER, name TEXT); INSERT INTO test VALUES (1, 'Alice'), (2, 'Bob')`)
async function run() {
const result = await db.exec("SELECT * FROM test")
console.log(result[0].values)
}
btn.addEventListener('click', run)
</script>
</body>
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open the README and find the current sample demo. Replace or revise it using the simpler JavaScript and SQL.js example in the issue, while retaining the previous-version example if it is useful. Done means the README presents the proposed browser demo accurately and its code is readable and runnable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, sqlite
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100