@@ -3,7 +3,12 @@ import type { Collection } from '../collection';
33import type { Server } from '../sdam/server' ;
44import type { ClientSession } from '../sessions' ;
55import { type TimeoutContext } from '../timeout' ;
6- import { decorateWithCollation , decorateWithReadConcern } from '../utils' ;
6+ import {
7+ decorateRawData ,
8+ decorateWithCollation ,
9+ decorateWithReadConcern ,
10+ maxWireVersion
11+ } from '../utils' ;
712import { CommandOperation , type CommandOperationOptions } from './command' ;
813import { Aspect , defineAspects } from './operation' ;
914
@@ -21,6 +26,12 @@ export type DistinctOptions = CommandOperationOptions & {
2126 * See https://www.mongodb.com/docs/manual/reference/command/distinct/#command-fields.
2227 */
2328 hint ?: Document | string ;
29+ /**
30+ * Used when the command needs to grant access to the underlying namespaces for time series collections.
31+ * Only available on server versions 8.2 and above.
32+ * @public
33+ **/
34+ rawData ?: boolean ;
2435} ;
2536
2637/**
@@ -61,6 +72,7 @@ export class DistinctOperation extends CommandOperation<any[]> {
6172 session : ClientSession | undefined ,
6273 timeoutContext : TimeoutContext
6374 ) : Promise < any [ ] > {
75+ const serverWireVersion = maxWireVersion ( server ) ;
6476 const coll = this . collection ;
6577 const key = this . key ;
6678 const query = this . query ;
@@ -94,6 +106,8 @@ export class DistinctOperation extends CommandOperation<any[]> {
94106 // Have we specified collation
95107 decorateWithCollation ( cmd , coll , options ) ;
96108
109+ decorateRawData ( cmd , ! ! this . options . rawData , serverWireVersion ) ;
110+
97111 const result = await super . executeCommand ( server , session , cmd , timeoutContext ) ;
98112
99113 // @ts -expect-error: Explain always returns a document
0 commit comments