如何在Angular 7中从Cosmos DB查询数据?
我试图用Angular在Cosmos DB中查询我的数据,希望填充图表(来自chart.js)来显示数据。我不确定您如何在angular中查询数据。现在,我有一些带有API的基本组件,可以从数据库中获取基本信息,但我不知道如何查询它。CosmosDB提供了一种访问文档的方法。例如:如何在Angular 7中从Cosmos DB查询数据?,angular,api,chart.js,azure-cosmosdb,Angular,Api,Chart.js,Azure Cosmosdb,我试图用Angular在Cosmos DB中查询我的数据,希望填充图表(来自chart.js)来显示数据。我不确定您如何在angular中查询数据。现在,我有一些带有API的基本组件,可以从数据库中获取基本信息,但我不知道如何查询它。CosmosDB提供了一种访问文档的方法。例如: @Injectable({ providedIn: 'root' }) export class CosmosDBService { constructor(private http: HttpCl
@Injectable({
providedIn: 'root'
})
export class CosmosDBService {
constructor(private http: HttpClient) { }
get(id: string) {
return this.http.get(
`https://${account}.documents.azure.com/dbs/${db}/colls/${collection}/docs/${id}`);
}
}
当然,您必须注意访问控制,并为请求设置正确的身份验证头()您是否厌倦了@azure/cosmos包?