Skip to content

Instantly share code, notes, and snippets.

collection.find().sort(new Document("offerAmount", 1)).skip(10).limit(30);
coll.find().map(new Function<Document, String>() {
@Override
public String apply(final Document document) {
return document.getString("name");
}
}).into(names, new SingleResultCallback<List<String>>() {
@Override
public void onResult(final List<String> names, final Throwable t) {
if (t != null) {
System.out.println("There was an error: " + t);
db.createCollection( "email", { storageEngine: {
wiredTiger: { configString: "blockCompressor=zlib" }}})
String xmlString = convertMapToXML(data);
<data>
<name>buzz</name>
<lastUpdate>20140606</lastUpdate>
<pets>
<pet>dog</pet>
<pet>cat</pet>
</pets>
<milestones>
actionArray = [
function one(cb) {
someAsyncFunction(params, function(err, results) {
if (err) {
cb(new Error(“There was an error”));
}
console.log(“one”);
cb(null);
});
},
dump/
└── [4.3M] country
├── [2.1M] austria.bson
├── [ 87] austria.metadata.json
├── [2.1M] nigeria.bson
├── [ 87] nigeria.metadata.json
└── [ 140] system.indexes.bson
1 directory, 5 files
<dependency>
<groupId>org.mongodb.mongo-hadoop</groupId>
<artifactId>mongo-hadoop-core</artifactId>
<version>1.4.0</version>
</dependency>
compile 'org.mongodb.mongo-hadoop:mongo-hadoop-core:1.4.0'
foo:PRIMARY> rs.printReplicationInfo()
configured oplog size: 192MB
log length start to end: 897secs (0.25hrs)
oplog first event time: Wed Jul 15 2015 13:21:10 GMT-0700 (PDT)
oplog last event time: Wed Jul 15 2015 13:36:07 GMT-0700 (PDT)
now: Wed Jul 15 2015 13:36:46 GMT-0700 (PDT)
replset:PRIMARY> rs.stepDown()
2015-06-16T16:01:25.298-0400 I NETWORK DBClientCursor::init call() failed
2015-06-16T16:01:25.303-0400 E QUERY Error: error doing query: failed
at DBQuery._exec (src/mongo/shell/query.js:83:36)
at DBQuery.hasNext (src/mongo/shell/query.js:240:10)
at DBCollection.findOne (src/mongo/shell/collection.js:187:19)
at DB.runCommand (src/mongo/shell/db.js:58:41)
at DB.adminCommand (src/mongo/shell/db.js:66:41)
at Function.rs.stepDown (src/mongo/shell/utils.js:1001:43)
at (shell):1:4 at src/mongo/shell/query.js:83