{"_id":"@caratlane/sqc","_rev":"1-c7a7306e8dfb7eff0744d4614f7b62d7","name":"@caratlane/sqc","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"@caratlane/sqc","version":"1.0.0","description":"This is a Sequelize instance plug-in that will prepend a SQL comment to the generated SQL statements based on the {options.comment} property.","main":"index.js","scripts":{"test":"node test.js"},"author":"","license":"ISC","devDependencies":{"chalk":"^1.1.3","mysql":"^2.13.0","sequelize":"^3.30.4"},"_id":"@caratlane/sqc@1.0.0","_nodeVersion":"16.4.2","_npmVersion":"8.19.2","dist":{"integrity":"sha512-BVuqx2JILvNyJglVO/iZS86Gt1Z3Qp0XHmB+QAOAgAgQjg0jvtoLomRmMcF2PzHd5RQup8yAnnlbR1Lm7CNOqQ==","shasum":"78ed9ee9bd0e04ef2bd98f941f49dbf5054fa36f","tarball":"https://registry.npmjs.org/@caratlane/sqc/-/sqc-1.0.0.tgz","fileCount":3,"unpackedSize":9693,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDrpR0nZy0zb+SCAKJo2kyc2aStDj1JCkFZ4S/6t6TeEQIhALcFAzNvfy11yZs0Yx/kXExbq1DHolN20bvqrcm77p/p"}]},"_npmUser":{"name":"caratlane","email":"architecturecouncil@caratlane.com"},"directories":{},"maintainers":[{"name":"caratlane","email":"architecturecouncil@caratlane.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sqc_1.0.0_1686131746674_0.5116622968756688"},"_hasShrinkwrap":false},"1.1.0":{"name":"@caratlane/sqc","version":"1.1.0","description":"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","main":"index.js","scripts":{"test":"node test.js"},"author":"","license":"ISC","devDependencies":{"chalk":"^1.1.3","mysql":"^2.13.0","sequelize":"^6"},"dependencies":{"mysql2":"^3.3.3"},"gitHead":"5ed59296616ac7c68c2c42b3c6a09cac8c00a331","_id":"@caratlane/sqc@1.1.0","_nodeVersion":"16.4.2","_npmVersion":"8.19.2","dist":{"integrity":"sha512-dqQwdTymcfNpq21VxXkvnLng7bvBsiayoBmwWiPM1cGdtzlo3w67FQkCmmH/4Zn+3/s126wsv5JL0ItjwY+9sQ==","shasum":"1db67218d66071fa802088da63226260e6f0c467","tarball":"https://registry.npmjs.org/@caratlane/sqc/-/sqc-1.1.0.tgz","fileCount":4,"unpackedSize":12851,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCQ5XrUH9UuumwtUHWlqPUS5q3BzILJxzKRlcpffeOeegIhAM37He4qSavKg8NIlYMLeHKUKaFLXtH6lt7+xMRn/nKe"}]},"_npmUser":{"name":"caratlane","email":"architecturecouncil@caratlane.com"},"directories":{},"maintainers":[{"name":"caratlane","email":"architecturecouncil@caratlane.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sqc_1.1.0_1686559526664_0.7752652374338267"},"_hasShrinkwrap":false}},"time":{"created":"2023-06-07T09:55:46.621Z","1.0.0":"2023-06-07T09:55:46.818Z","modified":"2023-06-12T08:45:26.878Z","1.1.0":"2023-06-12T08:45:26.771Z"},"maintainers":[{"name":"caratlane","email":"architecturecouncil@caratlane.com"}],"description":"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","license":"ISC","readme":"# SQC (Sequelize Query Commenter)\n\nversion 1.1.0 ( added support for v5 & v6 Sequalize)\n\n## Overview\nSQC (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.\n\nThis 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.\n\n## Installation\n\nYou can install the Sequelize SQL Query Commenter package using npm:\n\n```shell\nnpm install @caratlane/sqc\n```\n\n## Usage\n\nTo start using the sqc package, follow these steps:\n\nImport the package into your project:\n\n```js\nconst commentPlugin = require(\"@caratlane/sqc\");\n```\nAttach the sqc middleware to your Sequelize instance:\n\n```js\nconst Sequelize = require('sequelize');\nconst commentPlugin = require('@caratlane/sqc');\n\nlet sequelize = new Sequelize(/* your database configuration */);\n\n// Attach the query commenter middleware\nsequelize = commentPlugin(sequelize);\n\n```\nAdd comments to your queries:\n\n```js\nconst User = sequelize.define('User', {\n  name: Sequelize.STRING,\n  email: Sequelize.STRING\n});\n\n// Add a comment to the query\nconst users = await User.findAll({\n  where: { name: 'John Doe' },\n  comment: 'Retrieve users with name John Doe'\n});\n```\nRun your Sequelize queries as usual, and the comments will be automatically added to the generated SQL queries.\n\n```js\ncommentPlugin(sequelize)\n```\n\nAttaches the sqc middleware to the provided Sequelize instance.\n\nsequelize: The Sequelize instance to which the middleware will be attached.\nQuery Options\nThe 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.\n\ncomment (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.\nExamples\nHere are a few examples to illustrate how to use the Sequelize SQL Query Commenter:\n\n```js\nconst users = await User.findAll({\n  where: { age: { [Sequelize.Op.gte]: 18 } },\n  comment: 'Retrieve adult users'\n});\n\nconst updatedUser = await User.update(\n  { name: 'Jane Doe' },\n  {\n    where: { id: 1 },\n    comment: 'Update user name'\n  }\n);\n\nconst deletedRows = await User.destroy({\n  where: { age: { [Sequelize.Op.lt]: 18 } },\n  comment: 'Delete underage users'\n});\n\n```\n\nIn the above examples, the comments provided in the comment property will be automatically added to the generated SQL queries.\n\n## Acknowledgments\nThis 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.","readmeFilename":"README.md"}