在MongoDB兼容模式下,Firestore会报错:Firestore API数据访问已被禁用
使用NodeJS的 Firestore SDK:
initializeApp();
const db = getFirestore("db-name");
.....
const ref = db.doc(`${firestoreCollectionUsers}/${data.auth.uid}`);
const doc = await ref.get();
会产生一个错误:
错误: 9 FAILED_PRECONDITION: Firestore API数据访问已被禁用。若要通过Firestore API访问数据库,请启用它。
同一份代码在Native模式下的Firestore上可以正常工作。
请问我应该在哪里启用Firestore API数据访问?
解决方案
你的Firestore数据库正在Datastore模式运行,而不是原生模式。标准的Firestore SDK getFirestore() 仅在原生模式的Firestore上工作。
站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。