Skip to content

Instantly share code, notes, and snippets.

View ttrelle's full-sized avatar
🏢
I may be slow to respond.

Tobias Trelle ttrelle

🏢
I may be slow to respond.
View GitHub Profile
@ttrelle
ttrelle / vol_test.js
Last active January 29, 2016 10:39
MongoDB File Allocation Test
var DATA = "12345678";
var c = db.getCollection("volume");
function insert(n) {
var s = data();
for (i=0; i<n; i++) {
if (i%200 == 0) {
print(i);
}
var wr = c.insert({_id:i, s: s});
@ttrelle
ttrelle / 01_Intro.md
Last active August 29, 2015 14:04
MongoDB-Workshop > Test data > Points of Interest
  • Start up a mongod server
  • Run the mongo shell
  • Paste the content of the following JS file into the shell and press enter to execute

Check if there are 7 documents inserted by checking the result of

db.pois.count()

@ttrelle
ttrelle / 01_mongoshell.js
Created December 18, 2012 13:00
MongoDB: JSON vs. BSON
use test
db.foo.drop();
// in JSON all numbers are 32-bit floating point types (s. JSON spec)
// and thus are mapped to the 64-bit floating point type in BSON
db.foo.insert( {a: 1} )
@ttrelle
ttrelle / gist:3945598
Created October 24, 2012 11:36
Pessimistic Locking with MongoDB
db.workitem.lock.drop();
db.createCollection("workitem.lock");
db.workitem.lock.ensureIndex( { ts: 1 }, { expireAfterSeconds: 30 } );
db.workitem.lock.ensureIndex( { aid: 1 }, {unique: false} );
@ttrelle
ttrelle / 01_mongodb_live_hacking.md
Last active December 13, 2021 06:14
MongoDB Live Hacking Preparations

Download & Run MongoDB

  • Grab the latest stable release from the download page
  • Unzip the archive to a folder called ${MONGO_HOME} on your disk
  • Create a folder /data/db on the same drive/partition
  • Go to ${MONGO_HOME}/bin
  • Execute the binary mongod (or mongod.exe on Windows)

For a more detailed explanation, see the MongoDB installation guide.