#!upstart
description "Upstart script for yourapp Server"
start on startup
stop on shutdown
expect fork
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.copyDatabase("oldDb","newDb","connection") | |
use oldDb | |
db.dropDatabase(); |
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 options = { | |
server: { socketOptions: { keepAlive: 1, connectTimeoutMS: 30000 } }, | |
replset: { socketOptions: { keepAlive: 1, connectTimeoutMS: 30000 } } | |
}; | |
mongoose.connect(secrets.db, null, options); |
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
openssl genrsa -out server-key.pem 2048 | |
openssl req -new -key server-key.pem -out server-csr.pem | |
OR | |
openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr | |
and | |
openssl x509 -req -in server-csr.pem -signkey server-key.pem -out server-cert.pem | |
past in ssl provider: cat server-csr.pem |
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.getCollectionNames().forEach(function(collection) { | |
indexes = db[collection].getIndexes(); | |
print("Indexes for " + collection + ":"); | |
printjson(indexes); | |
}); |
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
agregação var = MyModel.aggregate (...); | |
aggregation.options = {allowDiskUse: true}; | |
aggregation.exec (function () {}); |
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
export LANGUAGE=en_US.UTF-8 | |
export LANG=en_US.UTF-8 | |
export LC_ALL=en_US.UTF-8 | |
locale-gen en_US.UTF-8 | |
dpkg-reconfigure locales |
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.collection.find({}).snapshot().forEach( function (obj) { | |
obj.prop1 = obj.prop2; | |
db.collection.save(obj); | |
}); | |
db.collection.find({}).snapshot().forEach( function (obj) { | |
obj.prop1 = parseInt(obj.prop1); | |
db.collection.save(obj); | |
}); |
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.collection | |
.aggregate( | |
[ | |
{$match:{$text:{$search: "STRING"}, {/*wEVER*/}}}, | |
{$lookup:{from: 'otherCollectionJoin', localField: 'p', foreignField: '_id', as: 'otherCollectionJoin'}}, | |
{$unwind:"otherCollectionJoin"}, | |
{ | |
$group:{ | |
"_id":"$_id" | |
, type: {$addToSet: "otherField"} |