/** * Creates a criterion ({@code $jsonSchema}) matching documents against a given structure defined by the * {@link MongoJsonSchema}. <br /> * <strong>NOTE:</strong> {@code $jsonSchema} cannot be used on field/property level but defines the whole document * structure. Please use * {@link org.springframework.data.mongodb.core.schema.MongoJsonSchema.MongoJsonSchemaBuilder#properties(JsonSchemaProperty...)} * to specify nested fields or query them using the {@link #type(Type...) $type} operator. * * @param schema must not be {@literal null}. * @return this * @since 2.1 * @see <a href="https://docs.mongodb.com/manual/reference/operator/query/jsonSchema/">MongoDB Query operator: * $jsonSchema</a> */ public Criteria andDocumentStructureMatches(MongoJsonSchema schema) { Assert.notNull(schema, "Schema must not be null!"); Criteria schemaCriteria = new Criteria(); schemaCriteria.criteria.putAll(schema.toDocument()); return registerCriteriaChainElement(schemaCriteria); }
/** * Creates an 'or' criteria using the $or operator for all of the provided criteria * <p> * Note that mongodb doesn't support an $or operator to be wrapped in a $not operator. * <p> * * @throws IllegalArgumentException if {@link #orOperator(Criteria...)} follows a not() call directly. * @param criteria */ public Criteria orOperator(Criteria... criteria) { BasicDBList bsonList = createCriteriaList(criteria); return registerCriteriaChainElement(new Criteria("$or").is(bsonList)); }
/** * Creates an 'and' criteria using the $and operator for all of the provided criteria. * <p> * Note that mongodb doesn't support an $and operator to be wrapped in a $not operator. * <p> * * @throws IllegalArgumentException if {@link #andOperator(Criteria...)} follows a not() call directly. * @param criteria */ public Criteria andOperator(Criteria... criteria) { BasicDBList bsonList = createCriteriaList(criteria); return registerCriteriaChainElement(new Criteria("$and").is(bsonList)); }
/** * Creates a 'nor' criteria using the $nor operator for all of the provided criteria. * <p> * Note that mongodb doesn't support an $nor operator to be wrapped in a $not operator. * <p> * * @throws IllegalArgumentException if {@link #norOperator(Criteria...)} follows a not() call directly. * @param criteria */ public Criteria norOperator(Criteria... criteria) { BasicDBList bsonList = createCriteriaList(criteria); return registerCriteriaChainElement(new Criteria("$nor").is(bsonList)); }
/** * Creates a criterion ({@code $jsonSchema}) matching documents against a given structure defined by the * {@link MongoJsonSchema}. <br /> * <strong>NOTE:</strong> {@code $jsonSchema} cannot be used on field/property level but defines the whole document * structure. Please use * {@link org.springframework.data.mongodb.core.schema.MongoJsonSchema.MongoJsonSchemaBuilder#properties(JsonSchemaProperty...)} * to specify nested fields or query them using the {@link #type(Type...) $type} operator. * * @param schema must not be {@literal null}. * @return this * @since 2.1 * @see <a href="https://docs.mongodb.com/manual/reference/operator/query/jsonSchema/">MongoDB Query operator: * $jsonSchema</a> */ public Criteria andDocumentStructureMatches(MongoJsonSchema schema) { Assert.notNull(schema, "Schema must not be null!"); Criteria schemaCriteria = new Criteria(); schemaCriteria.criteria.putAll(schema.toDocument()); return registerCriteriaChainElement(schemaCriteria); }
/** * Creates an 'and' criteria using the $and operator for all of the provided criteria. * <p> * Note that mongodb doesn't support an $and operator to be wrapped in a $not operator. * <p> * * @throws IllegalArgumentException if {@link #andOperator(Criteria...)} follows a not() call directly. * @param criteria */ public Criteria andOperator(Criteria... criteria) { BasicDBList bsonList = createCriteriaList(criteria); return registerCriteriaChainElement(new Criteria("$and").is(bsonList)); }
/** * Creates an 'or' criteria using the $or operator for all of the provided criteria * <p> * Note that mongodb doesn't support an $or operator to be wrapped in a $not operator. * <p> * * @throws IllegalArgumentException if {@link #orOperator(Criteria...)} follows a not() call directly. * @param criteria */ public Criteria orOperator(Criteria... criteria) { BasicDBList bsonList = createCriteriaList(criteria); return registerCriteriaChainElement(new Criteria("$or").is(bsonList)); }
/** * Creates a 'nor' criteria using the $nor operator for all of the provided criteria. * <p> * Note that mongodb doesn't support an $nor operator to be wrapped in a $not operator. * <p> * * @throws IllegalArgumentException if {@link #norOperator(Criteria...)} follows a not() call directly. * @param criteria */ public Criteria norOperator(Criteria... criteria) { BasicDBList bsonList = createCriteriaList(criteria); return registerCriteriaChainElement(new Criteria("$nor").is(bsonList)); }