Created
April 3, 2015 16:35
-
-
Save dalmat36/01e2ba0c702de5fef32d to your computer and use it in GitHub Desktop.
This code snippet shows how to find an existing document in a the MongoDB "people" collection and replace it.
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
| //Update a person document by Id | |
| Document updatedPerson = new Document("First Name", "Marilyn") | |
| .append("Last Name", "Monroe") | |
| .append("Description", "Actor"); | |
| collection.findOneAndReplace(eq("First Name", "Marilyn"), updatedPerson); | |
| System.out.println("Result After Update\n"); | |
| printAllPeople(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment