- The question of what "belongs" in a framework is complex, and depends on your use case. A better question is "what are the defaults?" By pulling all of the current features of Sails into plugins, and then including them by default, we provide full customizability (the possibility of disabling just about everything) without sacrificing all the conveniences Sails developers are used to.
- Plugins make it easier to contribute, and make modifying the core a much less scary proposition.
- Node.js is quite minimalist, and super awesome. Let's take a leaf out of Ryan/Isaac's book!
- Community plugins are fantastic, but to ensure quality, plugins will only be listed on the Sails website/repo when they've met some basic quality assurance testing.
Reference: https://gitter.im/balderdashy/sails?at=58be4b1af1a33b62758d57ea
Is there anyway that I can add a method to all routes?
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?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==================================================================================== | |
| // Example of iterating over the `where` clause from a stage 2 query from Waterline. | |
| // (the example below attempts to demonstrate a few of the most useful guarantees) | |
| // | |
| // > Mostly pay attention to the structure. Other than that, you can safely assume | |
| // > that, in short, everything is valid (+in a schema-aware way), guaranteed. | |
| // ==================================================================================== | |
| /* ~%° before iterating */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = { | |
| /** | |
| * | |
| * Using raw socket.io functionality from a Sails.js controller | |
| * | |
| */ | |
| index: function (req,res) { |
Some of the naming conventions we use at Sails for nouns like variables, parameters, property names, config settings, database attributes/columns/fields, and so on.
Naming is hard. And naming conventions usually end up being wrong, or incomplete at best.
This may be an unpopular opinion, but in my experience, coming up with new methodologies for variables and such doesn't usually create a lot of value for an individual developer. So why bother?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| cd /tmp || exit | |
| read -r -p "[s]table or [b]eta? [sS/bB] " choice | |
| choice=${choice,,} # tolower | |
| if [[ ! "$choice" =~ ^(s|b)$ ]]; then | |
| exit | |
| fi | |
| if [[ "$choice" = "s" ]]; then | |
| url=https://dl.pstmn.io/download/latest/linux64 | |
| name=Postman |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { parseArgs } from "node:util"; | |
| const args = parseArgs({ | |
| options: { | |
| name: { | |
| type: "string", | |
| }, | |
| verbose: { | |
| type: "boolean", | |
| short: "v", |
-- Firstly, remove PRIMARY KEY attribute of former PRIMARY KEY
ALTER TABLE <table_name> DROP CONSTRAINT <table_name>_pkey;-- Then change column name of your PRIMARY KEY and PRIMARY KEY candidates properly.
ALTER TABLE <table_name> RENAME COLUMN <primary_key_candidate> TO id;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Mute these words in your settings here: https://twitter.com/settings/muted_keywords | |
| ActivityTweet | |
| generic_activity_highlights | |
| generic_activity_momentsbreaking | |
| RankedOrganicTweet | |
| suggest_activity | |
| suggest_activity_feed | |
| suggest_activity_highlights | |
| suggest_activity_tweet |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Spiderman { | |
| lookOut() { | |
| alert('My Spider-Sense is tingling.'); | |
| } | |
| } | |
| let miles = new Spiderman(); | |
| miles.lookOut(); |
OlderNewer