Skip to content

Instantly share code, notes, and snippets.

View sgress454's full-sized avatar

Scott Gress sgress454

View GitHub Profile
@sgress454
sgress454 / saving-binary-data-using-waterline.md
Last active February 23, 2017 22:05
Saving binary data in a model using Waterline

Given the appropriate columnType, MySQL and PostgreSQL will handle storing buffers for you.

Model

module.exports = {
  attributes: {
    name: {
      type: 'string',
 },
@sgress454
sgress454 / custom-blueprint.md
Last active March 5, 2022 06:05
Adding a custom blueprint action to all models

Reference: https://gitter.im/balderdashy/sails?at=58be4b1af1a33b62758d57ea

Is there anyway that I can add a method to all routes?

The issue

Given a Sails app with two models User and Pet, how do we create a single controller action foo and have it automatically run on requests for both /user/foo and /pet/foo?

The solution

@sgress454
sgress454 / pre-commit
Created June 20, 2017 20:20
Pre-commit hook to block commits that change models without adding a migration script
#!/Users/scottmac/.nvm/v6.3.0/bin/node
/**
* Pre-commit hook to prevent commits that change models unless they
* also include a migration file.
*
* To skip, use the `--no-verify` option when committing.
* (useful if you just added a comment to a model)
*/
@sgress454
sgress454 / node-sql-parser-ast.json
Created April 14, 2025 19:02
node-sql-parser AST example
[
{
"with": [
{
"name": {
"type": "default",
"value": "extension_safety_hub_menu_notifications"
},
"stmt": {
"tableList": [