updates
This commit is contained in:
@ -8,7 +8,7 @@ impl Schema {
|
||||
pub fn compile_filter(
|
||||
&self,
|
||||
_db: &Database,
|
||||
_root_id: &str,
|
||||
root_id: &str,
|
||||
_errors: &mut Vec<crate::drop::Error>,
|
||||
) -> Option<Schema> {
|
||||
if let Some(props) = self.obj.compiled_properties.get() {
|
||||
@ -31,6 +31,48 @@ impl Schema {
|
||||
}
|
||||
|
||||
if !filter_props.is_empty() {
|
||||
let root_filter_type = format!("{}.filter", root_id);
|
||||
|
||||
let mut and_obj = SchemaObject::default();
|
||||
and_obj.type_ = Some(SchemaTypeOrArray::Multiple(vec![
|
||||
"array".to_string(),
|
||||
"null".to_string(),
|
||||
]));
|
||||
and_obj.items = Some(Arc::new(Schema {
|
||||
obj: SchemaObject {
|
||||
type_: Some(SchemaTypeOrArray::Single(root_filter_type.clone())),
|
||||
..Default::default()
|
||||
},
|
||||
always_fail: false,
|
||||
}));
|
||||
filter_props.insert(
|
||||
"$and".to_string(),
|
||||
Arc::new(Schema {
|
||||
obj: and_obj,
|
||||
always_fail: false,
|
||||
}),
|
||||
);
|
||||
|
||||
let mut or_obj = SchemaObject::default();
|
||||
or_obj.type_ = Some(SchemaTypeOrArray::Multiple(vec![
|
||||
"array".to_string(),
|
||||
"null".to_string(),
|
||||
]));
|
||||
or_obj.items = Some(Arc::new(Schema {
|
||||
obj: SchemaObject {
|
||||
type_: Some(SchemaTypeOrArray::Single(root_filter_type.clone())),
|
||||
..Default::default()
|
||||
},
|
||||
always_fail: false,
|
||||
}));
|
||||
filter_props.insert(
|
||||
"$or".to_string(),
|
||||
Arc::new(Schema {
|
||||
obj: or_obj,
|
||||
always_fail: false,
|
||||
}),
|
||||
);
|
||||
|
||||
let mut wrapper_obj = SchemaObject::default();
|
||||
// Conceptually link this directly into the STI lineage of the base `filter` object
|
||||
wrapper_obj.type_ = Some(SchemaTypeOrArray::Single("filter".to_string()));
|
||||
|
||||
Reference in New Issue
Block a user