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
param | |
( | |
[string] $inputFile, | |
[string] $outputFile | |
) | |
if (($inputFile -eq $null) -or ($outputFile -eq $null)) { | |
"usage: convert_csv_to_json.ps1 [inputFile] [outputFile]" | |
return; | |
} |
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
var MongoClient = require('mongodb').MongoClient; | |
MongoClient.connect('mongodb://localhost:27017/school', function(err, db) { | |
if(err) throw err; | |
db.collection('students').aggregate( | |
{'$unwind':'$scores'}, | |
{'$match':{'scores.type': 'homework'}}, | |
{'$group':{'_id':'$_id', | |
// 'scores':{$addToSet:'$scores.score'}, |
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
posts.update({"permalink": permalink}, {$push: { "comments": comment }}, function(err, doc) { | |
if (err) { | |
return callback(err, null) | |
} | |
else { | |
console.dir(doc + " : Comments added!") | |
return callback(null, doc); | |
} | |
}); |
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
posts.insert(post, function(err, doc){ | |
if (!err) { | |
console.log("Inserted new post"); | |
return callback(null, permalink); | |
} | |
return callback(err, null) | |
}); |
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
db.profile.find({ns:/school2.students/}, {millis: 1}).sort({millis: -1}).pretty() |
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
[ | |
{ | |
"v" : 1, | |
"key" : { | |
"_id" : 1 | |
}, | |
"ns" : "blog.posts", | |
"name" : "_id_" | |
}, | |
{ |
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
use blog | |
db.posts.aggregate([{ | |
$unwind: "$comments" | |
}, { | |
$group: { | |
_id: "$comments.author", | |
postcount: { | |
$sum: 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
use hw5 | |
db.zips.aggregate([ | |
/* First group via sum up of the values of the cities with the same name | |
this is because a city will have multiple zips therefore, | |
multiple entries of cities with the same name */ | |
{ | |
$group: { | |
_id: { state: "$state", city: "$city"}, | |
pop: { $sum: "$pop" } | |
} |
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
use hw5 | |
db.grades.aggregate([ | |
{ | |
$unwind: "$scores" | |
} | |
,{ | |
$match: { | |
"scores.type": { $ne: "quiz" } | |
} | |
} |
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
sudo bash < create_replica_set.sh | |
mongo --port 27018 < init_replica.js |
OlderNewer