From 9b88ae9a38bc6800829f8c90673be8fd1bd5f67a Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Thu, 13 Sep 2018 12:13:17 +0200 Subject: [PATCH] #405 - Polishing. Slight readme tweaks. Override flapdoodle version using the version property. --- mongodb/pom.xml | 5 ++++- mongodb/schema-validation/README.md | 9 +++++---- .../example/springdata/mongodb/schema/Application.java | 3 +++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/mongodb/pom.xml b/mongodb/pom.xml index a2daf322..140c1b82 100644 --- a/mongodb/pom.xml +++ b/mongodb/pom.xml @@ -32,6 +32,10 @@ schema-validation util + + + 2.1.1 + @@ -60,7 +64,6 @@ de.flapdoodle.embed de.flapdoodle.embed.mongo provided - 2.1.1 diff --git a/mongodb/schema-validation/README.md b/mongodb/schema-validation/README.md index 03be93f5..c484de17 100644 --- a/mongodb/schema-validation/README.md +++ b/mongodb/schema-validation/README.md @@ -18,15 +18,16 @@ MongoDB (as of version 3.2) supports validating documents against a given struct } } ``` + The structure can be built from `Criteria` objects in the same way as they are used for defining queries. ```java Validator.criteria(where("name").exists(true).ne(null).type(2) .and("age").exists(true).ne(null).type(16).gte(0).lte(125)); ``` - + MongoDB 3.6 supports collections that validate documents against a provided [JSON Schema](https://docs.mongodb.com/manual/core/schema-validation/#json-schema) that -complies to the JSON schema specification (draft 4). +complies with the JSON schema specification (draft 4). ```json { @@ -58,13 +59,13 @@ MongoJsonSchema schema = MongoJsonSchema.builder() // ).build(); ``` -The schema can not only be used to set up `Document` validation for a collection +The schema can be used for various funcitionality: Set up `Document` validation for a collection: ```java template.createCollection(Jedi.class, CollectionOptions.empty().validator(Validator.schema(schema))); ``` -but also to query the store for documents matching a given blueprint. +and to query the store for documents matching a given blueprint: ```java template.find(query(matchingDocumentStructure(schema)), Jedi.class); diff --git a/mongodb/schema-validation/src/main/java/example/springdata/mongodb/schema/Application.java b/mongodb/schema-validation/src/main/java/example/springdata/mongodb/schema/Application.java index 9f257760..86fa2348 100644 --- a/mongodb/schema-validation/src/main/java/example/springdata/mongodb/schema/Application.java +++ b/mongodb/schema-validation/src/main/java/example/springdata/mongodb/schema/Application.java @@ -17,5 +17,8 @@ package example.springdata.mongodb.schema; import org.springframework.boot.autoconfigure.SpringBootApplication; +/** + * @author Christoph Strobl + */ @SpringBootApplication public class Application {}