Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F8922898
query_or.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
query_or.js
View Options
const
Query
=
require
(
"./query.js"
);
const
QueryStep
=
require
(
"./query-step.js"
);
module
.
exports
=
class
extends
Query
{
constructor
(...
queries
)
{
super
();
this
.
lookup_steps
=
[];
for
(
let
query
of
queries
)
{
this
.
addQuery
(
query
);
}
}
addQuery
(
query
)
{
const
steps
=
query
.
dump
();
this
.
lookup_steps
.
push
(
...
steps
.
filter
(
step
=>
step
instanceof
QueryStep
.
Lookup
)
);
const
match_stage_bodies
=
[];
steps
.
filter
(
step
=>
step
instanceof
QueryStep
.
Match
)
.
forEach
(
step
=>
step
.
pushDump
(
match_stage_bodies
));
const
match_stage
=
match_stage_bodies
.
length
>
1
?
{
$and
:
match_stage_bodies
}
:
match_stage_bodies
[
0
];
this
.
steps
.
push
(
new
QueryStep
.
Match
(
match_stage
));
}
dump
()
{
return
this
.
lookup_steps
.
concat
(
new
QueryStep
.
Match
({
$or
:
this
.
_getMatchExpressions
()
})
);
}
toPipeline
()
{
const
lookups
=
this
.
lookup_steps
.
reduce
(
(
acc
,
step
)
=>
step
.
pushStage
(
acc
),
[]
);
return
lookups
.
concat
({
$match
:
{
$or
:
this
.
_getMatchExpressions
()
}
});
}
_getMatchExpressions
()
{
return
this
.
steps
.
reduce
((
acc
,
step
)
=>
step
.
pushDump
(
acc
),
[]);
}
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Sep 20, 15:01 (20 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
931148
Default Alt Text
query_or.js (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment