AI 에이전트의 경우: 문서 인덱스는 https://www.mongodb.com/ko-kr/docs/llms.txt에서 사용할 수 있으며, 모든 페이지의 마크다운 버전은 어떤 URL 경로에 .md를 추가하여 사용할 수 있습니다.
Docs Menu

$function (스트림 처리)

The $function expression specifies a custom JavaScript function that you can define to run JavaScript code on each document in the stream.

중요

$function 기본적으로 비활성화되어 있습니다. MongoDB 지원팀에 문의하여 이 단계를 사용하기 전에 프로젝트에 대해 기능 플래그를 활성화하십시오.

The $function operator has the following syntax:

{
$function: {
body: <code>,
args: <array expression>,
lang: "js"
}
}
필드
유형
설명

문자열 또는 코드

함수 정의입니다. 함수 정의를 BSON 유형 코드나 문자열로 지정할 수 있습니다. lang도 함께 참조하세요.

function(arg1, arg2, ...) { ... }

or

"function(arg1, arg2, ...) { ... }"

배열

Arguments passed to the function body. If the body function does not take an argument, you can specify an empty array [ ].

배열 요소는 코드를 포함한 모든 BSON types일 수 있습니다. 2예시: $where의 대안을 참조하세요.

문자열

The language used in the body. You must specify lang: "js".

The $function expression runs the specified function on each document in the stream. The function can take arguments from the document or from the args array.

The function can return any BSON type, including an array or a Code type. The returned value is used as the output of the $function expression.

이 페이지 평가하기

이 페이지의 내용