Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F996638
value-existing-in-collection.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
value-existing-in-collection.js
View Options
"use strict"
;
const
locreq
=
require
(
"locreq"
)(
__dirname
);
const
assert
=
require
(
"assert"
);
const
Promise
=
require
(
"bluebird"
);
module
.
exports
=
function
(
app
)
{
return
{
name
:
"value-existing-in-collection"
,
is_proper_value
:
async
function
(
context
,
params
,
new_value
)
{
assert
.
equal
(
typeof
params
.
field
,
"string"
);
assert
(
typeof
params
.
include_forbidden
===
"boolean"
||
params
.
include_forbidden
===
undefined
);
const
collection
=
params
.
collection
;
assert
(
collection
instanceof
app
.
Sealious
.
Collection
);
await
collection
.
fields
[
params
.
field
].
is_proper_value
(
context
,
new_value
);
if
(
params
.
include_forbidden
)
{
context
=
new
app
.
Sealious
.
SuperContext
();
}
const
sealious_response
=
await
app
.
run_action
(
context
,
[
"collections"
,
collection
.
name
],
"show"
,
{
filter
:
{
[
params
.
field
]
:
new_value
},
}
);
if
(
sealious_response
.
empty
)
{
return
Promise
.
reject
(
`No
${
collection
.
name
}
with
${
params
.
field
}
set to
${
new_value
}
`
);
}
},
encode
:
async
function
(
context
,
params
,
value_in_code
,
old_value
)
{
return
params
.
collection
.
fields
[
params
.
field
].
encode
(
context
,
value_in_code
,
old_value
);
},
format
:
function
(
context
,
params
,
decoded_value
,
format
)
{
return
params
.
collection
.
fields
[
params
.
field
].
format
(
context
,
decoded_value
,
format
);
},
filter_to_query
:
function
(
context
,
params
,
field_filter
)
{
return
params
.
collection
.
fields
[
params
.
field
].
filter_to_query
(
context
,
field_filter
);
},
get_aggregation_stages
:
function
(
context
,
params
,
field_name
,
query
)
{
return
params
.
collection
.
fields
[
params
.
field
].
get_aggregation_stages
(
context
,
field_name
,
query
);
},
};
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 24, 14:06 (9 m, 53 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
557353
Default Alt Text
value-existing-in-collection.js (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment