@@ -16,6 +16,11 @@ import { firestore as createFirestore, firestoreSymbol } from "./firebase.mjs";
1616 */
1717export const nativeSymbol = Symbol ( "native" ) ;
1818
19+ /**
20+ * The symbol allows to access the Typesaurus database instance.
21+ */
22+ export const dbSymbol = Symbol ( "db" ) ;
23+
1924export function schema ( getSchema , options ) {
2025 let firestore ;
2126 const schema = getSchema ( schemaHelpers ( ) ) ;
@@ -142,6 +147,7 @@ export class Collection {
142147 return new SubscriptionPromise ( {
143148 request : request ( {
144149 [ nativeSymbol ] : doc ,
150+ [ dbSymbol ] : this . db ,
145151 kind : "get" ,
146152 path : this . path ,
147153 id,
@@ -171,6 +177,7 @@ export class Collection {
171177 return new SubscriptionPromise ( {
172178 request : request ( {
173179 [ nativeSymbol ] : docs ,
180+ [ dbSymbol ] : this . db ,
174181 kind : "many" ,
175182 path : this . path ,
176183 ids,
@@ -235,6 +242,7 @@ export class Collection {
235242
236243 adapter ( ) {
237244 return {
245+ db : ( ) => this . db ,
238246 collection : ( ) => this . firebaseCollection ( ) ,
239247 doc : ( snapshot ) =>
240248 new Doc ( this , snapshot . id , wrapData ( this . db , snapshot . data ( ) ) ) ,
@@ -345,6 +353,7 @@ export function all(adapter) {
345353 return new SubscriptionPromise ( {
346354 request : request ( {
347355 [ nativeSymbol ] : firebaseCollection ,
356+ [ dbSymbol ] : adapter . db ( ) ,
348357 kind : "all" ,
349358 ...adapter . request ( ) ,
350359 } ) ,
@@ -629,6 +638,7 @@ export function query(firestore, adapter, queries) {
629638 const sp = new SubscriptionPromise ( {
630639 request : request ( {
631640 [ nativeSymbol ] : firestoreQuery ,
641+ [ dbSymbol ] : adapter . db ( ) ,
632642 kind : "query" ,
633643 ...adapter . request ( ) ,
634644 queries : queries ,
0 commit comments