Used in a template function to create a condition that is true if no matching fact exists.
static notExists<T>(
template: Partial<T>
): Condition<T>;
type
and predecessorssuchThat
or not
Return only facts that do not have a specified successor.
function messagesInChannel(c) {
return j.match({
type: 'Chat.Message',
channel: c
}).suchThat(messageIsNotRedacted);
}
function messageIsNotRedacted(m) {
return j.notExists({
type: 'Chat.Message.Redacted',
message: m
});
}
The above can be expressed in terms of exists
and not
.
The result is the same.
function messagesInChannel(c) {
return j.match({
type: 'Chat.Message',
channel: c
}).suchThat(j.not(messageIsRedacted));
}
function messageIsRedacted(m) {
return j.exists({
type: 'Chat.Message.Redacted',
message: m
});
}
Double negatives are supported. They are just hard to read.
function publishedPostsInFolder(f) {
return j.match({
type: 'Blog.Post',
folder: f
}).suchThat(j.not(postIsNotPublished));
}
function postIsNotPublished(p) {
return j.notExists({
type: 'Blog.Post.Published',
post: p
});
}