File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @blinkk/root-cms ' : patch
3
+ ---
4
+
5
+ feat: add option for listing raw docs
Original file line number Diff line number Diff line change @@ -105,6 +105,11 @@ export interface ListDocsOptions {
105
105
orderBy ?: string ;
106
106
orderByDirection ?: 'asc' | 'desc' ;
107
107
query ?: ( query : Query ) => Query ;
108
+ /**
109
+ * Whether to fetch the "raw" version of the doc (for use in conjunction with
110
+ * `setRawDoc()`).
111
+ */
112
+ raw ?: boolean ;
108
113
}
109
114
110
115
export interface GetCountOptions {
@@ -306,8 +311,15 @@ export class RootCMSClient {
306
311
const results = await query . get ( ) ;
307
312
const docs : T [ ] = [ ] ;
308
313
results . forEach ( ( result ) => {
309
- const doc = unmarshalData ( result . data ( ) ) as T ;
310
- docs . push ( doc ) ;
314
+ if ( options . raw ) {
315
+ // For callers that wish to modify the raw doc via `setRawDoc()`,
316
+ // return the unmodified doc as returned from firestore.
317
+ const rawDoc = result . data ( ) as T ;
318
+ docs . push ( rawDoc ) ;
319
+ } else {
320
+ const doc = unmarshalData ( result . data ( ) ) as T ;
321
+ docs . push ( doc ) ;
322
+ }
311
323
} ) ;
312
324
return { docs} ;
313
325
}
You can’t perform that action at this time.
0 commit comments