Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for converting column names to camelCase #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kuzzmi
Copy link

@kuzzmi kuzzmi commented Aug 19, 2021

This adds a support for passing column name through camelCase from lodash during file generation.

Not sure about the configuration option tho, please let me know if you have a different vision.

@bhenderson
Copy link
Contributor

I was looking for a feature like this. Although, I think the configuration should be a custom function that we can pass in. I ended up hacking it like this:

// naive way to append Table to all types generated.
const overrides = new Proxy(
  {},
  {
    get(target, name) {
      // original behavior
      const value = upperFirst(camelCase(name.replace(/[.-]/g, '_')));

      return `Table${value}`;
    },
  }
);

updateTypes(db, { overrides })

this isn't a perfect solution because overrides are used for more than just column names.

@koistya
Copy link
Member

koistya commented Aug 28, 2021

Extending overrides option to allow passing a custom function would be great!

updateTypes(db, {
  overrides: {
    "picture_url": "PictureURL",
    "*": (name, type) => type === "column" ? toCamelCase(name) : name
  }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants