Angular7 Firestore导入DocumentReference类

时间:2018-11-09 14:41:21

标签: javascript angular typescript firebase google-cloud-firestore

如何获取DocumentReference类以及如何将其与路径字符串一起使用?有什么想法吗?

我尝试过:

import DocumentReference = firebase.firestore.DocumentReference;

但是它不能解决我的问题。

在查询用户uid的引用数组以检查它们是否在此数组中时,我需要使用它。

.collection('chats', ref => ref.where('members', 'array-contains', new DocumentReference(`/users/${user.uid}`)))

错误消息:

ERROR in src/app/core/firebase/chat.service.ts(11,28): error TS2686: 'firebase' refers to a UMD global, but the current file is a module. Consider adding an import instead.
src/app/core/firebase/chat.service.ts(47,80): error TS2673: Constructor of class 'DocumentReference' is private and only accessible within the class declaration.

更新#1:

将导入更改为:

import {firestore} from 'firebase';
import DocumentReference = firestore.DocumentReference;

现在错误更改为:

ERROR in src/app/core/firebase/chat.service.ts(47,80): error TS2673: Constructor of class 'DocumentReference' is private and only accessible within the class declaration.

答案:Firestore where 'array-contains' query doesn't work with references

0 个答案:

没有答案