mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-24 18:31:41 +01:00
added ~= operation to create Where clauses for value arrays
This commit is contained in:
@@ -233,6 +233,18 @@ public extension ValueContainer.Required {
|
|||||||
|
|
||||||
return Where("%K >= %@", attribute.keyPath, value)
|
return Where("%K >= %@", attribute.keyPath, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates a `Where` clause from a `CoreStoreObject.Value` property.
|
||||||
|
```
|
||||||
|
let dog = CoreStore.fetchOne(From<Dog>(), Dog.where { ["Pluto", "Snoopy", "Scooby"] ~= $0.nickname })
|
||||||
|
```
|
||||||
|
*/
|
||||||
|
@inline(__always)
|
||||||
|
public static func ~= <S: Sequence>(_ sequence: S, _ attribute: ValueContainer<O>.Required<V>) -> Where where S.Iterator.Element == V {
|
||||||
|
|
||||||
|
return Where(attribute.keyPath, isMemberOf: sequence)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -263,6 +275,18 @@ public extension ValueContainer.Optional {
|
|||||||
|
|
||||||
return !Where(attribute.keyPath, isEqualTo: value)
|
return !Where(attribute.keyPath, isEqualTo: value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates a `Where` clause from a `CoreStoreObject.Value` property.
|
||||||
|
```
|
||||||
|
let dog = CoreStore.fetchOne(From<Dog>(), Dog.where { ["Pluto", "Snoopy", "Scooby"] ~= $0.nickname })
|
||||||
|
```
|
||||||
|
*/
|
||||||
|
@inline(__always)
|
||||||
|
public static func ~= <S: Sequence>(_ sequence: S, _ attribute: ValueContainer<O>.Optional<V>) -> Where where S.Iterator.Element == V {
|
||||||
|
|
||||||
|
return Where(attribute.keyPath, isMemberOf: sequence)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user