Skip to content

Instantly share code, notes, and snippets.

@nazt
Forked from anonymous/gist:3246797
Created August 3, 2012 11:27
Show Gist options
  • Select an option

  • Save nazt/3246802 to your computer and use it in GitHub Desktop.

Select an option

Save nazt/3246802 to your computer and use it in GitHub Desktop.
/// 1
db.open(function (err, client) {
client.createCollection("docs", function (err, col) {
client.collection("docs", function (err, col) {
for (var i = 0; i < 100; i++) {
col.insert({
c: i
}, function () {});
}
});
});
});
/// 2
Step(
function () {
db.open(this);
},
function (err, client) {
client.createCollection("docs", this);
},
function (err, col) {
for (var i = 0; i < 100; i++) {
col.insert({
c: i
});
}
});
/// 3
db.open(createCollection)
function createCollection(err, client) {
client.createCollection('docs', insertData)
}
function insertData(err, col) {
for (var i = 0; i < 100; i++) {
col.insert({
c: i
}, function () {})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment