Skip to content

How can graaljs not merge Array? #838

@k1tano

Description

@k1tano

script like "const avgSendReceiveDiff = db.chatGptMessage.aggregate([
{
$project: {
created_by: 1,
timeDifference: { $subtract: ["$receive_time", "$send_time"] }
}
},
{
$group: {
_id: "$created_by",
avgTimeDifference: { $avg: "$timeDifference" }
}
}
])"
When i use context.eval("js",script)
I expected the "$subtract: ["$receive_time", "$send_time"]" stay unchanged and mongo java driver can parse, but when i extract the string, it was serialize into " $subtract: Array(2)", and mongodb can not parse.
How can i fix this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions