kossnocorp / typesaurus

🦕 Type-safe TypeScript-first ODM for Firestore
https://typesaurus.com
412 stars 34 forks source link

query(actually all the APIs) doesn't work when admin.initializeApp() with cross project #92

Closed zhenhao18 closed 3 months ago

zhenhao18 commented 3 years ago

Hello man,

My function works in firebase Project A, but need access firestore in Project B, with recommended code snippet typeSaurus only talked with Project A, rather than B. I got this error "The Cloud Firestore API is not available for Datastore Mode projects."

import * as admin from 'firebase-admin'
import { collection, get, all, query, where } from 'typesaurus'

admin.initializeApp() // default init
admin.initializeApp({project-A-config-option})  // Project A init
admin.initializeApp({project-B-config-option}) // Project B init

type User = { name: string }
const users = collection<User>('users')

// Query collection
query(users, [where('name', '===', 'Sasha')])   //  ==> this won't work, and complains with error ''The Cloud Firestore API is not available for Datastore Mode projects."

I can understand typeSaurus is trying to connect with fireStore of Project A, but how to talk with Project B?

Thanks very much. Regard Zhen

harshmaur commented 2 years ago

I'm having similar problem.

kossnocorp commented 3 months ago

It has been fixed via v10, and its schema options: https://typesaurus.com/api/schema/#app