小编Eri*_*ric的帖子

Firestore:检索单个文档

我想从 Firestore 检索单个文档。所以我的意思不是集合中的文档列表(我知道怎么做)。假设我知道文档的键值对之一,我想查找文档并将其检索到 Angular 4 中。

interface Occupations {
	duration: number;
	id_entity: number;
	id_job: number;
	id_user: number;
	salary: number;
	start_time: number;
}

occupationDoc:AngularFirestoreDocument<Occupations>;
occupation: Observable<Occupations>;
Run Code Online (Sandbox Code Playgroud)
<h1>A specific post:</h1>

  <h3>{{ (occupation | async)?.salary }}</h3>
  <p>{{ (occupation | async)?.id_user }}</p> 
  <p>{{ (occupation | async)?.duration }}</p> 
  <p>{{ (user | async)?.lastName }}</p> 
Run Code Online (Sandbox Code Playgroud)

javascript rxjs angular google-cloud-firestore angularfire5

5
推荐指数
1
解决办法
9056
查看次数

我可以在函数(不是函数组件)内使用钩子吗

这是我想使用我的钩子的地方,以便我可以在应用程序运行期间更改一种状态。

export const simpleFunction = () => (state) => {
   // here is the hook 
}
Run Code Online (Sandbox Code Playgroud)

我知道反应钩子应该用在功能组件中,但是上面提到的情况又如何呢?

javascript reactjs react-hooks

2
推荐指数
1
解决办法
4662
查看次数