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