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
FeedItem.aggregate({ | |
// you want to group all the things by status key | |
$group: { | |
_id: '$statusName', // assuming you have `statusName` field in your collections, prefix with `$`. | |
timeOn: { | |
// $cond takes 3 arguments as an array, cond expression, true expression and false expression | |
$cond: [ | |
// if event was active, we want to add the milliseconds to timeOn | |
{ $eq: [ "$wasActive", true ] }, | |
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 co from 'co' | |
// Generator controller, | |
// this.models refers to Sequelize models added with server.bind() | |
function* loginController(request) { | |
let user = yield this.models.User.find({ | |
where: { | |
email: request.payload.email | |
} |
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
var Promise = require('bluebird'); | |
function doSomethingAsync(data, callback) { | |
return $blueBirdPromise | |
.tap(function() { | |
console.log('Op is successful'); | |
}) | |
.nodeify(callback); | |
}; |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
language: node_js | |
node_js: ["0.11", "0.10"] | |
env: | |
CODECLIMATE_REPO_TOKEN: <your_token> | |
before_script: | |
- npm install -g istanbul | |
- npm install -g mocha | |
- npm install -g codeclimate-test-reporter |
NewerOlder