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

Support limiting length of strings #29

Open
zygopleural opened this issue Sep 30, 2022 · 3 comments
Open

Support limiting length of strings #29

zygopleural opened this issue Sep 30, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@zygopleural
Copy link
Contributor

At the moment, in order to limit the length of strings, I need to do:

const User = createModel((User) => {
  User
    .string("id", { id: true })
    .string("setupId", { raw: "@database.VarChar(36)" })
})

It would be nice to support something like

const User = createModel((User) => {
  User
    .string("id", { id: true })
    .string("setupId", { maxLength: 36 })
})

or

const User = createModel((User) => {
  User
    .string("id", { id: true })
    .varChar("setupId", { limit: 36 })
})

or

const User = createModel((User) => {
  User
    .string("id", { id: true })
    .varChar("setupId", 36)
})

In order to add the "@database.VarChar(36)" automatically.

@ridafkih
Copy link
Owner

The difficulty here would be that different database engines support different datatypes, so we'll need to map those out.

@zygopleural
Copy link
Contributor Author

The difficulty here would be that different database engines support different datatypes

I was under the assumption this library only supported postgres

@ridafkih
Copy link
Owner

ridafkih commented Oct 2, 2022

@zygopleural At the moment, yes, it primarily supports Postgres, but I also use it personally for cockroachdb. We could implement these features open-ended so it's still expected that the user knows which method to use for their database engine, we could compute it on our end, or we could default to postgres and provide the functionality to override. Quite a few avenues there.

@ridafkih ridafkih added the enhancement New feature or request label May 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants