bormashino-sequel-sqljs-adapter
SQL.JS adapter for Sequel on browser with Bormaŝino / ruby.wasm
Demo
https://bormashino-sequel-sqljs-adapter.vercel.app/
Quickstart
on typical bormashino-app-template project
$ npm i bormashino-sequel-sqljs-adapter
$ (cd src && bundle add bormashino-sequel-sqljs-adapter)
app.js
import initSqlJs from 'sql.js'
import sqlWasm from 'url:../node_modules/sql.js/dist/sql-wasm.wasm'
import { dbWrapper } from 'bormashino-sequel-sqljs-adapter'
const SQL = await initSqlJs({ locateFile: () => sqlWasm })
const db = new SQL.Database()
window.database = dbWrapper(db)
app.rb
require 'sequel'
require 'bormashino_sequel_sqljs_adapter'
# sqljs://<name of dbWrapper instance under window object>
@db = Sequel.connect('sqljs://database')
@db.create_table :items do
primary_key :id
String :name
Float :price
end
items = @db[:items]
Release
rubygem
$ cd gem
$ bundle exec rake build
$ gem push pkg/bormashino-sequel-sqljs-adapter-XXX.gem
npm package
$ cd npm
$ npm publish