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

명령 예제 실행

RunCommand() 메서드를 사용하여 MongoDB 서버에서 직접 명령을 실행할 수 있습니다.

팁

이 예시를 실행하는 방법에 대해 알아보려면 사용 예시를 읽어보세요.

다음 예시에서는 sample_restaurants 데이터베이스에 대한 통계를 조회합니다.

db := client.Database("sample_restaurants") // Retrieves statistics about the specified databasecommand := bson.D{{"dbStats", 1}} var result bson.M// Runs the command and prints the database statisticserr := db.RunCommand(context.TODO(), command).Decode(&result) // Prints a message if any errors occur during the command executionif err != nil { panic(err)}

완전히 실행 가능한 예시 보기

전체 예시를 실행하면 다음 값이 포함된 SingleResult 형식이 반환됩니다.

// results truncated{ "avgObjSize": 548.4101901854896, "collections": 2, "dataSize": 14014074, "db": "sample_restaurants", "indexSize": 286720, ...,}

참고

result 변수는 컬렉션 콘텐츠에 따라 달라질 수 있습니다.

RunCommand()

이 페이지 평가하기