Replies: 2 comments 12 replies
-
and other question is how to remove a column from types ? |
Beta Was this translation helpful? Give feedback.
2 replies
-
The @Test
public void testContains() {
String className = "testContains";
DocumentType clazz1 = database.getSchema().createDocumentType(className);
clazz1.createProperty("list", Type.LIST);
database.getSchema().createDocumentType("embeddedList");
database.transaction(() -> {
for (int i = 0; i < 100; i++) {
MutableDocument document = database.newDocument(className);
document.set("list", new ArrayList<>());
for (int j = i; j < i + 3; j++)
document.newEmbeddedDocument("embeddedList", "list").set("value", j);
document.save();
}
});
int totalFound = 0;
for (ResultSet result = database.query("sql", "select from " + className + " where list contains ( value = 3 )"); result.hasNext(); ) {
Result item = result.next();
List<EmbeddedDocument> embeddedList = item.getProperty("list");
List<Integer> valueMatches = new ArrayList<>();
for (EmbeddedDocument d : embeddedList)
valueMatches.add(d.getInteger("value"));
Assertions.assertTrue(valueMatches.contains(3));
++totalFound;
}
Assertions.assertEquals(3, totalFound);
} |
Beta Was this translation helpful? Give feedback.
10 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have field named
stages
like this:then I want to fetch records stages have
t
= 10001, query wrote like this, but not work, always return empty result:then rewrote to, and this time got the matched records:
I want to know how
contains*
functions workBeta Was this translation helpful? Give feedback.
All reactions