Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F7860002
aggregate.ts
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
808 B
Referenced Files
None
Subscribers
None
aggregate.ts
View Options
import
{
CalculatedField
,
Context
,
App
,
Queries
,
Collection
,
CollectionItem
,
}
from
"../../../main"
;
type
StagesGetter
=
(
context
:
Context
,
item
:
CollectionItem
,
db_document
:
any
)
=>
Queries
.
QueryStage
[];
export
default
class
Aggregate
extends
CalculatedField
<
any
>
{
name
=
"aggregate"
;
stages_getter
:
StagesGetter
;
constructor
(
app
:
App
,
collection
:
Collection
,
stages_getter
:
StagesGetter
)
{
super
(
app
,
collection
);
this
.
stages_getter
=
stages_getter
;
}
async
calculate
(
context
:
Context
,
item
:
CollectionItem
,
db_document
:
any
)
{
const
stages
=
this
.
stages_getter
(
context
,
item
,
db_document
);
const
documents
=
await
this
.
app
.
Datastore
.
aggregate
(
this
.
collection
.
name
,
stages
);
if
(
documents
.
length
)
{
return
documents
[
0
].
result
;
}
else
{
return
null
;
}
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Aug 13, 17:13 (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
870066
Default Alt Text
aggregate.ts (808 B)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment