Skip to content

Instantly share code, notes, and snippets.

@anidotnet
Created May 11, 2017 03:40
Show Gist options
  • Save anidotnet/ceca3efc429c1fdaa120a3d0dec8c4cf to your computer and use it in GitHub Desktop.
Save anidotnet/ceca3efc429c1fdaa120a3d0dec8c4cf to your computer and use it in GitHub Desktop.
Nitrite Introduction
Cursor cursor = collection.find(
// and clause
and(
// firstName == John
eq("firstName", "John"),
// elements of data array is less than 4
elemMatch("data", lt("$", 4)),
// elements of fruits list has one element matching orange
elemMatch("fruits", regex("$", "orange")),
// note field contains string 'quick' using full-text index
text("note", "quick")
)
);
for (Document document : cursor) {
// process the document
}
// create document by id
Document document = collection.getById(nitriteId);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment