Kequc / knex-stringcase

Helper switches key case for npm knex
https://www.npmjs.com/package/knex-stringcase
ISC License
52 stars 8 forks source link

Does the Usage Example still work #28

Open dmathewwws opened 1 week ago

dmathewwws commented 1 week ago

Hey,

Just checking if this example still works or has been changed because of the recent typescript changes.

import knex from 'knex';
import knexStringcase from 'knex-stringcase';

const db = knex({
  client: 'mysql',
  connection: {
    host: '127.0.0.1',
    user: 'your_database_user',
    password: 'your_database_password',
    database: 'myapp_test'
  },
  ...knexStringcase(),
});

I get the following error: knexStringcase is not a function when i try to run it

Zjaaspoer commented 1 week ago

Indeed, same here

Kequc commented 4 days ago

Seems to be the same error discussed here.

https://github.com/Kequc/knex-stringcase/issues/27

I'm a bit at a loss for what I'm supposed to be doing. I thought I set it up with CommonJS as a focus, but it is affecting more people than I expected. Can you guys see anywhere in the code that it can be improved?

Otherwise the solution seems to be somewhere here:

const knexStringcase - require('knex-stringcase');
const knexStringcase = require('knex-stringcase').default;
import knexStringcase from 'knex-stringcase';
import { default as knexStringcase } from 'knex-stringcase';
dmathewwws commented 4 days ago

This worked for me:

import knex from 'knex';
import knexStringcase from 'knex-stringcase';

const db = knex({
  client: 'mysql',
  connection: {
    host: '127.0.0.1',
    user: 'your_database_user',
    password: 'your_database_password',
    database: 'myapp_test'
  },
   ...knexStringcase.default(),
});
Kequc commented 3 days ago

Yea. I'd really rather fix this. I think there's some Typescript configuration setting that needs to be on to avoid it, but I'd really rather not have to worry about it.

I could switch away from using a default export.