vitonsky, vitonsky@programming.dev
Instance: programming.dev
Joined: 2 years ago
Posts: 11
Comments: 1
Open source enthusiast.
- Creator of Linguist - a browser extension for privacy focused translation (FOSS)
- Author of blog about programming
Posts and Comments by vitonsky, vitonsky@programming.dev
Comments by vitonsky, vitonsky@programming.dev
When you use query builder, you write a raw SQL code.
The benifit is you can insert user input right in string, and your query remain secure against injections. Additionally, a Nano Queries let you compose queries, and extend it, so you may build complex queries simply.
Let’s say you develop a site to search something by its features, for example a movies. Your SQL query may easy takes 100-500 lines. Some part of this query will be a basic, some will be optional depends on provided filters.
With a query builder you may conditionally extend your query like that
if (userInput.rating > 0) {
filter.and(sql`rating >= ${userInput.rating}`);
}
That’s all Query Builder does. It let you avoid to write code like that
const values = [];
const getPlaceholder = (value) => {
values.push(value);
return `$${values.length}`;
};
const where = [];
if (year) {
where.push(`release_year = ${getPlaceholder(year)}`);
}
if (rating) {
where.push(`rating >= ${getPlaceholder(rating)}`);
}
db.query(
`SELECT title FROM movies ${where.length ? 'WHERE ' + where.join(' AND ') : ''} LIMIT 100`,
values,
);
c/programming
When you use query builder, you write a raw SQL code.
The benifit is you can insert user input right in string, and your query remain secure against injections. Additionally, a Nano Queries let you compose queries, and extend it, so you may build complex queries simply.
Let’s say you develop a site to search something by its features, for example a movies. Your SQL query may easy takes 100-500 lines. Some part of this query will be a basic, some will be optional depends on provided filters.
With a query builder you may conditionally extend your query like that
That’s all Query Builder does. It let you avoid to write code like that
Nano Queries, a state of the art Query Builder (vitonsky.net)
Ordinality - framework-agnostic migrations tool for Browser, Node, Deno (github.com)
Ordinality let you manage any changes in your system via declarative actions, and a storage that remember applied actions.
Ordinality - framework-agnostic migrations tool for Browser, Node, Deno (github.com)
Ordinality may be used to migrate scheme in your postgres database, to migrate from a JSON file to a database and back, to copy files from SSD to a S3, etc.
Open source product is a marketing tool (vitonsky.net)
Open source is a promotion tool (vitonsky.net)
Open source is a promotion tool (vitonsky.net)
Don't Guess My Language (vitonsky.net)
IP tells you where the request comes from, that’s it. It doesn’t tell you what language the user speaks. It looks like Google thinks otherwise, and many programmers are blindly repeating it for Google with no idea how do it properly.
plausible-client: Collect analytics in browser with no hassle (github.com)
Software with politic opinion is are security threat (vitonsky.net)
Software with politic opinion is are security threat (vitonsky.net)
eslint-plugin-paths: A plugin for ESLint, to force use paths aliases from tsconfig (github.com)