This file contains 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
// Let the collection's name is 'students' & we want to speed up the query's performance on the 'students' collection when we find documents in the collection by 'student_id'. | |
// In order to achieve this, we'll add an index for the 'student_id' column where we want to index it by ascending order. | |
db.students.ensureIndex({'student_id': 1}) | |
// Another case is when we want to speed up query which takes both 'student_id' & 'class' columns where the class would be descending order. | |
db.students.ensureIndex({'student_id':1, 'class':-1}) |
This file contains 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
// Creating root category | |
db.categories.insert({'_id': 0, 'name': 'Computer Hardware' }) | |
// Creating 1st level category | |
db.categories.insert({'_id': 1, 'name': 'Computer Components', 'parent_id': 0, 'ancestors': [0]}) | |
// Creating 2nd level categories | |
db.categories.insert({'_id': 2, 'name': 'CPUs', 'parent_id': 1, 'ancestors': [1, 0]}) | |
db.categories.insert({'_id': 3, 'name': 'Motherboards', 'parent_id': 1, 'ancestors': [1, 0]}) | |
db.categories.insert({'_id': 4, 'name': 'Memory', 'parent_id': 1, 'ancestors': [1, 0]}) |
This file contains 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
// Prepare sample data on the Teachers collection | |
db.teachers.insert({'_id': 0, 'name': 'Maria'}) | |
db.teachers.insert({'_id': 1, 'name': 'Jill'}) | |
db.teachers.insert({'_id': 2, 'name': 'Anna'}) | |
db.teachers.insert({'_id': 3, 'name': 'Lara'}) | |
// Prepare sample data on the Students collection | |
db.students.insert({'_id':0, 'name':'Lisa', 'teachers': [0,1]}) | |
db.students.insert({'_id':1, 'name':'Paulene', 'teachers': [0,1,3]}) | |
db.students.insert({'_id':2, 'name':'Joey', 'teachers': [1,2,3]}) |
This file contains 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
// Initialise Express | |
var express = require('express'), | |
app = express(); | |
// Initialise Consolidate | |
var consolidate = require('consolidate'); | |
// setup swig as the view html engine | |
app.engine("html", consolidate.swig); | |
app.set("view engine", "html"); |
This file contains 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
hello_world: (req, res) -> res.json({hello: 'world'}) | |
^ | |
SyntaxError: Unexpected token > | |
at Module._compile (module.js:439:25) | |
at Object.Module._extensions..js (module.js:474:10) | |
at Module.load (module.js:356:32) | |
at Function.Module._load (module.js:312:12) | |
at Module.require (module.js:364:17) | |
at require (module.js:380:17) | |
at /home/wendysa/Documents/Excercises/demo_sails/node_modules/sails/node_modules/include-all/index.js:96:53 |
This file contains 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
## | |
^ | |
SyntaxError: Unexpected token ILLEGAL | |
at Module._compile (module.js:439:25) | |
at Object.Module._extensions..js (module.js:474:10) | |
at Module.load (module.js:356:32) | |
at Function.Module._load (module.js:312:12) | |
at Module.require (module.js:364:17) | |
at require (module.js:380:17) | |
at /home/wendysa/Documents/Excercises/demo_sails/node_modules/sails/node_modules/include-all/index.js:96:53 |
This file contains 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 = { | |
## | |
# Action blueprints: | |
# `/home/index` | |
# `/home` | |
# | |
hello_world = req, res -> res.json({hello: 'world'}) | |
} |
This file contains 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.routes = { | |
// By default, your root route (aka home page) points to a view | |
// located at `views/home/index.ejs` | |
// | |
// (This would also work if you had a file at: `/views/home.ejs`) | |
'/': { | |
controller: 'HomeController', | |
action: 'hello_world' | |
} |
This file contains 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
/** | |
* HomeController | |
* | |
* @module :: Controller | |
* @description :: A set of functions called `actions`. | |
* | |
* Actions contain code telling Sails how to respond to a certain type of request. | |
* (i.e. do stuff, then send some JSON, show an HTML page, or redirect to another URL) | |
* | |
* You can configure the blueprint URLs which trigger these actions (`config/controllers.js`) |
This file contains 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
using System; | |
using System.IO; | |
using Amazon.S3.Model; | |
using Amazon.S3.Transfer; | |
namespace GuestBook.Repository.Aws.S3 | |
{ | |
class GuestBookImageRepository : S3RepositoryBase, IGuestBookImageRepository | |
{ |