Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F12656051
value-not-existing-in-collection.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
value-not-existing-in-collection.ts
View Options
import
ValueExistingInCollection
from
"./value-existing-in-collection.js"
;
import
{
Context
,
Field
}
from
"../../../main.js"
;
import
{
OpenApiTypes
}
from
"../../../schemas/open-api-types.js"
;
export
default
class
ValueNotExistingInCollection
extends
ValueExistingInCollection
{
getTypeName
=
()
=>
"value-not-existing-in-collection"
;
open_api_type
=
OpenApiTypes
.
NONE
;
// unknown without context :C
async
isProperValue
(
context
:
Context
,
new_value
:
unknown
,
old_value
:
unknown
)
{
const
field
=
this
.
getField
(
context
.
app
);
if
(
!
field
)
{
throw
new
Error
(
"field is missing"
);
}
await
field
.
checkValue
(
context
,
new_value
,
old_value
,
null
);
if
(
this
.
include_forbidden
)
{
context
=
new
this
.
app
.
SuperContext
();
}
const
sealious_response
=
await
field
.
collection
.
list
(
context
)
.
filter
({
[
field
.
name
]
:
new_value
})
.
fetch
();
if
(
!
sealious_response
.
empty
)
{
return
Field
.
invalid
(
context
.
i18n
`Collection
${
field
.
collection
.
name
}
already has a record with '
${
field
.
name
}
' set to '
${
String
(
new_value
)
}
'.`
);
}
return
Field
.
valid
();
}
getPostgreSqlFieldDefinitions
()
:
string
[]
{
const
baseFieldsDefs
=
super
.
getPostgreSqlFieldDefinitions
();
return
baseFieldsDefs
.
map
((
field
)
=>
`
${
field
}
UNIQUE`
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Fri, Nov 28, 15:09 (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1080618
Default Alt Text
value-not-existing-in-collection.ts (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment