gothinkster / koa-knex-realworld-example

240 stars 79 forks source link

fix knex initialization problem when using sqlite3 #6

Closed edwardkcyu closed 6 years ago

edwardkcyu commented 6 years ago

This PR is to fix the knex initialization error when using sqlite3 (#3) with the solution from @beatgates.

I can reproduce the error in Window but not in Mac, not quite sure about the reason. Generally the solution can work for both cases.

With reference to the official doc, the correct initialization config for sqlite3 should contain the filename property.

var knex = require('knex')({
  client: 'sqlite3',
  connection: {
    filename: "./mydb.sqlite"
  }
});

compared to the PostgreSQL, only connection string is needed

var pg = require('knex')({
  client: 'pg',
  connection: process.env.PG_CONNECTION_STRING,
  searchPath: ['knex', 'public'],
});
edwardkcyu commented 6 years ago

changes have been updated