MongoDB Exercise in mongo shell
Connect to a running mongo instance, use a database named mongo_practice
.
Document all your queries in a javascript file to use as a reference.
"use strict" | |
const buildLetterMap = (str) => { | |
let letterMap = {}; | |
str.split("").forEach(function(letter) { | |
if(letterMap[letter]) { | |
letterMap[letter] = letterMap[letter] + 1; | |
} else { | |
letterMap[letter] = 1; |
'use strict' | |
const makeMeFlat = (arr) => { | |
let output = []; //define what we want to eventually return | |
if (arr && Array.isArray(arr)) { //make sure there is an input and it's an array | |
for(var i = 0; i < arr.length; i++) { //Loop through input | |
if (Array.isArray(arr[i])) { //The parameter is an array, we need to look into this; recursively | |
output = output.concat(makeMeFlat(arr[i])); //Redefine `output` as itself with the array concactenated to it, while recursively looping through the parameter | |
} else { | |
output.push(arr[i]); //The parameter is not an array, send it to the output | |
} |
/*jslint es6, node: true */ | |
(function () { | |
"use strict"; | |
const express = require('express'); | |
const router = express.Router(); | |
const Lesson = require('../models').Lesson; | |
const getAllLessons = function () { |
angular.module('starter') | |
.controller('SmsController', ['$ionicPlatform', '$scope', '$cordovaSms', | |
function($ionicPlatform, $scope, $cordovaSms) { | |
console.log('inside'); | |
$ionicPlatform.ready(function (){ | |
$scope.sendSms = function (){ | |
var number = '15169650711'; | |
var message = 'Hello World'; |
Before starting run the commands brew doctor
and then brew update
Unix Users please install using the docs
$ brew install mongodb
Once brew is done installing, take note of the Caveats section that is printed to your console. Just like what we did previously for postgres it might be best to create a symlink then two aliases to start and stop the mongo progress.
Basic authentication is one of the simplest authentication strategies because it doesn't require cookies, sessions, or even a login form! Instead, it uses HTTP headers which means credentials are transmitted on each request.
You will need to install passport
and passport-http
. The passport-http
module is what allows you set up the Basic Authentication Scheme, in addition to a couple other authentication strategies.
$ npm install express passport passport-http --save
var keepAliveAgent = new http.Agent({ | |
keepAlive: true, | |
keepAliveMsecs : 200 }); | |
var options = { | |
hostname : HOST, | |
port : PORT, | |
method : 'POST', | |
agent : keepAliveAgent | |
} |
Based off of: http://docs.sequelizejs.com/en/1.7.0/articles/express/
Create and initialize your a directory for your Express application.
$ mkdir sequelize-demo