Simpler demo

Đang mở
#603 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
48/100
Loại issue
Tài liệu
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
javascript, sqlite
Lĩnh vực
documentation

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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>
Ngôn ngữ chính
JavaScript
Star
13.7k
Fork
1.1k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của sql-js/sql.js

Tất cả issue của sql-js/sql.js

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.