[COMPASS-5112] $function NOT working in Node → Returns error 31261 Created: 27/Sep/21  Updated: 16/Nov/21  Resolved: 27/Sep/21

Status: Closed
Project: Compass
Component/s: Aggregation pipeline, Export to Language
Affects Version/s: None
Fix Version/s: 1.29.4

Type: Bug Priority: Blocker - P1
Reporter: max matinpalo Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Node 16.9.1


Attachments: File pipelineBug.js    
Issue Links:
Related
related to COMPASS-4835 Compass export to languages does not ... Closed
Documentation Changes: Not Needed

 Description   

$function works fine in compass but not in Node

Created example pipeline with $function inside compass → works fine.

Exporting this pipeline to node throws error 31261.

Pipeline in attachment.



 Comments   
Comment by max matinpalo [ 27/Sep/21 ]

Thank You very much Alena for your fast solution  

Comment by Alena Khineika [ 27/Sep/21 ]

The error that currently accrues is: `MongoError: Invalid $addFields :: caused by :: The body function must be specified`

The node driver expects the $function's body to be a string. With the 1.28.5 Compass release, we will provide a fix for the `Export to Language` module so the $function's body will be exported as a string instead of an object value.

Generated at Wed Feb 07 22:38:28 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.