From ddd394ffc3c03b3989cc346e5f72789010b6535c Mon Sep 17 00:00:00 2001 From: denis_savitsky Date: Sun, 8 Oct 2023 12:30:47 +0200 Subject: [PATCH] Add examples to readme --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index fb8c679..baef12b 100644 --- a/README.md +++ b/README.md @@ -194,6 +194,8 @@ val q3 = query[Person](p => Pattern.matches("^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4 V Array Query Operators +1. $size + ```scala import oolong.dsl.* @@ -204,6 +206,21 @@ val q = query[Course](_.studentNames.length == 20) // q is {"studentNames": {"$size": 20}} ``` +2. $elemMatch + +```scala +import oolong.dsl.* + +case class Course(studentNames: List[String], tutor: String) + +val q = query[Course](_.studentNames.exists(_ == 20)) // $elemMatch ommited when querying single field +// q is {"studentNames": 20} + +val q = query[Course](course => course.studentNames.exists(_ > 20) && course.tutor == "Pavlov") +// q is {"studentNames": {"$elemMatch": {"studentNames": {"$gt": 20}, "tutor": "Pavlov"}}} + +``` + #### Update operators I Field Update Operators