Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F8929542
IsReferencedByResourcesMatching.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
IsReferencedByResourcesMatching.js
View Options
const
locreq
=
require
(
"locreq"
)(
__dirname
);
const
assert
=
require
(
"assert"
);
const
Collection
=
locreq
(
"lib/chip-types/collection"
);
const
Query
=
locreq
(
"lib/datastore/query.js"
);
module
.
exports
=
app
=>
{
const
parametrized
=
app
.
SpecialFilter
.
WithParams
(
class
IsReferencedByResourcesMatching
extends
app
.
SpecialFilter
{
constructor
(
params
)
{
const
{
collection
,
referencing_field
,
field_to_check
,
allowed_values
,
nopass_reason
,
}
=
params
;
super
(
params
);
assert
(
params
);
assert
(
collection
);
assert
(
collection
instanceof
Collection
);
assert
(
collection
.
fields
[
referencing_field
]);
assert
(
collection
.
fields
[
field_to_check
]);
assert
(
Array
.
isArray
(
allowed_values
));
assert
(
typeof
nopass_reason
===
"string"
);
}
async
getFilteringQuery
()
{
const
query
=
new
Query
();
const
lookup_id
=
query
.
lookup
({
from
:
this
.
params
.
collection
.
name
,
localField
:
"sealious_id"
,
foreignField
:
`body.
${
this
.
params
.
referencing_field
}
`
,
});
query
.
match
({
[
`
${
lookup_id
}
.body.
${
this
.
params
.
field_to_check
}
`
]
:
{
$in
:
this
.
params
.
allowed_values
,
},
});
return
query
;
}
getNopassReason
()
{
return
this
.
params
.
nopass_reason
;
}
}
);
app
.
SpecialFilter
.
IsReferencedByResourcesMatching
=
parametrized
;
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Sep 20, 23:14 (20 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
949733
Default Alt Text
IsReferencedByResourcesMatching.js (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment