npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@caratlane/sqc

v1.1.0

Published

SQC (Sequelize Query Commenter) is a package that enables you to add comments to your SQL queries when using the Sequelize ORM (Object-Relational Mapping) with Node.js. It allows you to annotate your queries with meaningful comments, making it easier to u

Downloads

6,006

Readme

SQC (Sequelize Query Commenter)

version 1.1.0 ( added support for v5 & v6 Sequalize)

Overview

SQC (Sequelize Query Commenter) is a package that enables you to add comments to your SQL queries when using the Sequelize ORM (Object-Relational Mapping) with Node.js. It allows you to annotate your queries with meaningful comments, making it easier to understand and maintain your database interactions.

This package provides a simple and convenient way to add comments to your SQL queries without modifying the underlying Sequelize code. By leveraging Sequelize hooks and middlewares, it intercepts and modifies the generated SQL queries to include user-defined comments.

Installation

You can install the Sequelize SQL Query Commenter package using npm:

npm install @caratlane/sqc

Usage

To start using the sqc package, follow these steps:

Import the package into your project:

const commentPlugin = require("@caratlane/sqc");

Attach the sqc middleware to your Sequelize instance:

const Sequelize = require('sequelize');
const commentPlugin = require('@caratlane/sqc');

let sequelize = new Sequelize(/* your database configuration */);

// Attach the query commenter middleware
sequelize = commentPlugin(sequelize);

Add comments to your queries:

const User = sequelize.define('User', {
  name: Sequelize.STRING,
  email: Sequelize.STRING
});

// Add a comment to the query
const users = await User.findAll({
  where: { name: 'John Doe' },
  comment: 'Retrieve users with name John Doe'
});

Run your Sequelize queries as usual, and the comments will be automatically added to the generated SQL queries.

commentPlugin(sequelize)

Attaches the sqc middleware to the provided Sequelize instance.

sequelize: The Sequelize instance to which the middleware will be attached. Query Options The Sequelize SQL Query Commenter extends the Sequelize query options with an additional comment property. You can include this property in your queries to add a comment to the generated SQL query.

comment (string): The comment to be added to the SQL query. It should be a descriptive string that provides additional context or information about the query. Examples Here are a few examples to illustrate how to use the Sequelize SQL Query Commenter:

const users = await User.findAll({
  where: { age: { [Sequelize.Op.gte]: 18 } },
  comment: 'Retrieve adult users'
});

const updatedUser = await User.update(
  { name: 'Jane Doe' },
  {
    where: { id: 1 },
    comment: 'Update user name'
  }
);

const deletedRows = await User.destroy({
  where: { age: { [Sequelize.Op.lt]: 18 } },
  comment: 'Delete underage users'
});

In the above examples, the comments provided in the comment property will be automatically added to the generated SQL queries.

Acknowledgments

This package was inspired by the need to add comments to Sequelize SQL queries and aims to provide a simple and flexible solution. Special thanks to the Sequelize and Node.js communities for their valuable contributions.