This file contains hidden or 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
| MongoClient mongoClient = new MongoClient(new MongoClientURI("mongodb://localhost:27017")); |
This file contains hidden or 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
| MongoClient mongoClient = new MongoClient(); |
This file contains hidden or 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 database = mongoClient.getDB("TheDatabaseName"); |
This file contains hidden or 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
| DBCollection collection = database.getCollection("TheCollectionName"); |
This file contains hidden or 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
| List<Integer> books = Arrays.asList(27464, 747854); | |
| DBObject person = new BasicDBObject("_id", "jo") | |
| .append("name", "Jo Bloggs") | |
| .append("address", new BasicDBObject("street", "123 Fake St") | |
| .append("city", "Faketon") | |
| .append("state", "MA") | |
| .append("zip", 12345)) | |
| .append("books", books); |
This file contains hidden or 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
| MongoClient mongoClient = new MongoClient(); | |
| DB database = mongoClient.getDB("Examples"); | |
| DBCollection collection = database.getCollection("people"); | |
| collection.insert(person); |
This file contains hidden or 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
| collection.insert(PersonAdaptor.toDBObject(myPerson)); |
This file contains hidden or 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
| DBObject query = new BasicDBObject("_id", "jo"); | |
| DBCursor cursor = collection.find(query); |
This file contains hidden or 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
| DBObject jo = cursor.one(); |
This file contains hidden or 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
| (String)cursor.one().get("name"); |
OlderNewer