-
Notifications
You must be signed in to change notification settings - Fork 36
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
Better Documentation #180
Comments
Thank you for your feedback.
I agree that the usage between Using a global connection can lead to data inconsistencies, because a connection is not really meant to be shared across requests. In practice this means you'll almost certainly want to use We have talked internally about updating the -export function connect(config: Config): Connection {
- return new Connection(config)
+export function connect(config: Config): Client {
+ return new Client(config)
} But we hadn't yet because of backwards compatibility. Often people use database-js through an ORM eg. Drizzle, Prisma. Older versions of Drizzle (<0.29.4) (and Prisma) did not accept It's been almost half a year since Drizzle started to accept
They are not the same. By design @mattrobenolt did a deep-dive into the nuances, I highly recommend reading it if you want to get a deeper understanding. drizzle-team/drizzle-orm#1743 (comment).
Database-js is made for being used within serverless environments, you don't have to worry about managing your database connections.
|
This is super helpful. Thank you so much. Can you speak at all to the parameterized SQL calls and how you prevent SQL injections? Do you think you will add an API guide to the documentation? I have no plans to use an ORM and fully intend on writing all my own SQL queries and keeping them in my codebase. Thank you. |
You can either use the built-in escaping, or use an external library, like sqlstring. String interpolation would not be safe. (Ref)
What are you looking for exactly? The API surface is pretty small and should be fully covered with the README. We do welcome any contributions to make things better.
This is perfectly reasonable. |
So just to be clear, doing this is safe against SQL injections:
|
Correct. |
I just started using the Planetscale serverless driver for JavaScript, but I'm having a hard time understanding it. The documentation explains the very basics but doesn't go into detail on any of the return objects to the provided functions, why you would want to use any of the things provided over the other, nor any caveats I should/shouldn't know. All of the provided objects/classes/types in javascript lack JsDocs.
Having detailed documentation is useful so developers can quickly understand how to use the library without having to tinker and try things out. I've provided some examples below that could be improved on, but it's not a comprehensive list.
The docs say that we can connect to our DB with
connect
andClient
, but they don't explain why I would want to use one over the other apart from this lineThe
Client
class has aexecute
function but also has another function calledconnection
which returns aConnection
object, which also has anexecute
function. Why are there two? Are they actually the same? When do I use one over the other?There's also no mention of pooling, which I'm not even sure matters for serverless, but I feel like it should be addressed so I'm not overloading my DB with connections.
I'm also assuming that parameterized SQL calls won't cause me to have a SQL injection. You have an article here but it doesn't address this library at all.
Etc.
Thank you
The text was updated successfully, but these errors were encountered: