sql.js icon indicating copy to clipboard operation
sql.js copied to clipboard

sql.js can work with sequelize?

Open keyiis opened this issue 7 years ago • 5 comments

sql.js can work with sequelize?

keyiis avatar Dec 19 '16 07:12 keyiis

I'm so surprised this has never been done before, since it's so accessible but so in need of some sugar. This is, however, less a sql.js problem and more a sequelize problem ( as well as other sql ORMs / layers like knex ). Check out #91 - specifically the two replies. Some have made sql.js work with sequelize by patching together an adapter. Give that a try.

haltcase avatar Dec 20 '16 00:12 haltcase

@citycide i tried,but not work,i hope sql.js can give a offical example in document.

keyiis avatar Jan 02 '17 15:01 keyiis

It's not sequelize, but it might be useful anyway - I've just put out a 1.0 rc for a package I've been working on for a while that allows for using sql.js as a knex backend, along with a document store style API.

Trilogy

haltcase avatar Jan 17 '17 02:01 haltcase

TypeORM has sql.js support. https://www.npmjs.com/package/typeorm

I know it's not the answer you hoped for, but TypeORM can be used in javascript projects and I personally find it to be the best ORM I've come across in the node ecosystem.

@citycide is right; this is an ORM's feature to add. Sql.js can't do much about the issue directly without getting it's hands dirty in other teams projects.

KyleGalvin avatar Mar 28 '18 23:03 KyleGalvin

Hi. I've made an npm package that could be used to make sql.js to work with Sequelize by mimicking sqlite3's behavior: https://www.npmjs.com/package/sql.js-as-sqlite3

Usage:

import Sequelize from 'sequelize'
import sqlJsAsSqlite3 from 'sql.js-as-sqlite3'

const sequelize = new Sequelize('sqlite://dbname', {
  dialectModule: sqlJsAsSqlite3
})

Originally based on this gist: https://gist.github.com/iPotaje/89f48328c682b8a4f6f0b6e3874a6902

catamphetamine avatar Jun 26 '23 12:06 catamphetamine