
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
A lightweight and flexible CRUD utility for PostgreSQL, making SQL queries easier.
pgcrudify is a lightweight and efficient PostgreSQL query builder for performing Create, Read, Update, and Delete (CRUD) operations. It provides a simple API to interact with your PostgreSQL database without writing raw SQL queries.
npm install pgcrudify
import { createQuery, readQuery, updateQuery, deleteQuery } from "pgcrudify";
Ensure you have a PostgreSQL client (like pg package) set up:
import pg from "pg";
const db = new pg.Pool({
user: "your_user",
host: "your_host",
database: "your_database",
password: "your_password",
port: 5432,
});
const newUser = await createQuery(db, "users", { name: "John Doe", age: 25 }, ["id", "name"]);
console.log(newUser.rows);
db → Database connection
"users" → Table name
{ name: "John Doe", age: 25 } → Object containing data to insert
["id", "name"] → Fields to return after insertion (provide ["*"] to return all fields, if empty [] nothing is returned)
conflictAction (Optional) → handle conflicts that may arise due to unique constraints or primary key violations in PostgreSQL, (Default: "")
It allows defining whether to ignore conflicts (DO NOTHING) or update certain fields (DO UPDATE).
If conflictAction is an empty string "", the query proceeds as a normal INSERT without handling conflicts.
errorMethod (Optional) → The errorMethod parameter determines how errors are handled when executing queries. (Default: throw)
errorMethod = throw → Stops execution immediately if an error occurs
errorMethod = return → Returns the error object so you can handle it manually.
const users = await readQuery(db, "users", ["*"], { age: 25 });
console.log(users.rows);
db → Database connection
"users" → Table name
["*"] → Returns all columns (if empty [], an error is thrown, for specific fields ["name", "id])
{ age: 25 } → Filters records where age = 25,
{age:25, id:12} → Filters records where age = 25 and id = 12errorMethod (Optional) → The errorMethod parameter determines how errors are handled when executing queries. (Default: throw)
errorMethod = throw → Stops execution immediately if an error occurs
errorMethod = return → Returns the error object so you can handle it manually.
const updatedUser = await updateQuery(db, "users", { age: 26 }, { name: "John Doe" }, ["age"]);
console.log(updatedUser.rows);
{ age: 26 } → Fields to update
{ name: "John Doe" } → Filters records where name = John Doe,
{age:25, name: "John Doe" } → Filters records where age = 25 and name = John Doe["age"] → Returns updated field values (if empty [], nothing is returned, ["*"] Returns all columns)
errorMethod (Optional) → The errorMethod parameter determines how errors are handled when executing queries. (Default: throw)
errorMethod = throw → Stops execution immediately if an error occurs
errorMethod = return → Returns the error object so you can handle it manually.
const deletedUser = await deleteQuery(db, "users", { name: "John Doe" }, ["id"]);
console.log(deletedUser.rows);
{ name: "John Doe" } → Condition for deletion
{age:25, name: "John Doe" } → delete records where age = 25 and name = John DoedeleteQuery(db, "users", {}) → Deletes all rows if an empty object {} is provided
["id"] → Returns deleted row ID (provide ["*"] to return all fields, if empty [] nothing is returned)
errorMethod (Optional) → The errorMethod parameter determines how errors are handled when executing queries. (Default: throw)
errorMethod = throw → Stops execution immediately if an error occurs
errorMethod = return → Returns the error object so you can handle it manually.
All functions return errors if something goes wrong. You can choose how to handle them:
try {
await createQuery(db, "users", { name: 123 });
} catch (error) {
console.error("Error:", error.message);
}
returningFields | Behavior |
|---|---|
[] | No fields returned |
["*"] | All fields returned |
["id", "name"] | Only specified fields returned |
pgcrudify makes it easy to perform CRUD operations in PostgreSQL with a clean and structured API. 🚀 Happy coding!
Contributions are welcome! Please open an issue or submit a pull request on the https://github.com/sahanse/pgcrudify
MIT License
FAQs
A lightweight and flexible CRUD utility for PostgreSQL, making SQL queries easier.
We found that pgcrudify demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.