Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F3010851
negate-stage.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
842 B
Referenced Files
None
Subscribers
None
negate-stage.ts
View Options
import
type
{
MatchBody
}
from
"./query-stage"
;
export
default
function
negate_match
(
stage
:
MatchBody
)
{
const
negated_stage
:
MatchBody
=
{};
for
(
const
key
in
stage
)
{
if
(
key
===
"$or"
)
{
negated_stage
.
$nor
=
stage
.
$or
;
}
else
if
(
key
===
"$nor"
)
{
negated_stage
.
$or
=
stage
.
$nor
;
}
else
if
(
key
===
"$and"
)
{
negated_stage
.
$or
=
stage
.
$and
?
.
map
((
expression
:
MatchBody
)
=>
negate_match
(
expression
)
);
}
else
{
if
((
stage
[
key
]
as
MatchBody
).
$not
)
{
negated_stage
[
key
]
=
(
stage
[
key
]
as
MatchBody
)
.
$not
as
MatchBody
;
}
else
if
(
typeof
stage
[
key
]
==
"boolean"
)
{
negated_stage
[
key
]
=
!
stage
[
key
];
}
else
if
(
typeof
stage
[
key
]
!==
"object"
)
{
negated_stage
[
key
]
=
{
$not
:
{
$eq
:
stage
[
key
]
}
};
}
else
{
negated_stage
[
key
]
=
{
$not
:
stage
[
key
]
};
}
}
}
return
negated_stage
;
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Wed, May 7, 19:48 (1 d, 1 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
625678
Default Alt Text
negate-stage.ts (842 B)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment