HTTP/1.1 200 OK
Date: Thu, 05 Dec 2019 18:30:39 GMT
Content-Type: application/json
Content-Length: 365
Server: Jetty(9.4.22.v20191022)
[
{
"empId": "f843e184-46f0-4967-b3e1-fecbb4dfcf23",
"address": "From Memory. 123, North Pole."
},
{
"empId": "6a75a311-5cb7-44fd-9ca8-1b7a86ea3b22",
"address": "From Memory. 123, North Pole."
},
{
"empId": "c2e3c339-26b3-4bb9-8823-41bc94e90065",
"address": "From Memory. 123, North Pole."
},
{
"empId": "1d40b65a-4ef7-4acf-973e-2b327f591629",
"address": "From Memory. 123, North Pole."
}
]
Response code: 200 (OK); Time: 35ms; Content length: 365 bytes
Nitrite.builder().openOrCreate()
before every insert call, which is actually resetting the memory store before every insert.
Hi, I am not sure I understand the find API for a specific use case.. say I have some JSON as follows...
"tags": [
{
"type": "example"
}
],
How do I write a find query that returns documents that have a tag where the key is type
or documents that have a type field with the value example?
elemMatch
filter here.public void testCollectionField() {
Document document = createDocument("name", "John")
.put("tags", new Document[] {
createDocument("type", "example").put("other", "value"),
createDocument("type", "another-example").put("other", "some-other-value")
});
NitriteCollection example = db.getCollection("example");
example.insert(document);
document = createDocument("name", "Jane")
.put("tags", new Document[] {
createDocument("type", "example2").put("other", "value2"),
createDocument("type", "another-example2").put("other", "some-other-value2")
});
example.insert(document);
DocumentCursor cursor = example.find(elemMatch("tags", eq("type", "example")));
for (Document doc : cursor) {
System.out.println(doc);
}
}
NitriteDataGate.java
from datagate.