英文:
How to get firestore data without using firebase library
问题
I am new in using firestore. 我是新手使用Firestore。
I am working on a project where new requirement came as i have to fetch data from firestore. 我正在处理一个项目,新要求是我必须从Firestore中获取数据。
But the problem is my server is of old version where i can not install any firebase packages due to older version of server. 但问题是我的服务器是旧版本,由于服务器版本较旧,无法安装任何Firebase包。
How can i bypass installing firebase packages. 我如何绕过安装Firebase包。
I tried to get data from api as 我尝试从API获取数据如下
but the format i am receiving data is complex as below 但我收到的数据格式如下所示
> "name": "projects/$ProjectId/databases/(default)/documents/$path",
> "fields": {
> "Key1": {
> "stringValue": "Value1"
> },
> "Key2": {
> "stringValue": "Value2"
> },
> "Key3": {
> "stringValue": "value3"
> },
This String value and other data type is creating problem i want this data in simple json or Map<key,value format> 这个字符串值和其他数据类型正在创建问题,我希望将这些数据转换为简单的JSON或Map<key,value格式>
I have all the firebase access like apiKey and other credentials if required. 如果需要,我拥有所有Firebase访问权限,如apiKey和其他凭据。
How can i get that? 我该如何获得它? 谢谢。
英文:
I am new in using firestore .I am working on a project where new requirement came as i have to fetch data from firestore.But the problem is my server is of old version where i can not install any firebase packages due to older version of server .How can i bypass installing firebase packages.
i tried to get data from api as
but the format i am receiveing data is complex as below
> "name": "projects/$ProjectId/databases/(default)/documents/$path",
> "fields": {
> "Key1": {
> "stringValue": "Value!"
> },
> "Key2": {
> "stringValue": "Value2"
> },
> "Key3": {
> "stringValue": "value3"
> },
This String value and other data type is creating problem i want this data in simple json or Map<key,value format>
I have all the firebase access like apiKey and other credentials if required
how can i get that
Thanks
答案1
得分: 1
我明白您使用的服务器无法支持Firestore Admin SDKs之一。
据我所知,除了使用Admin SDK之外,从服务器与Firestore数据库交互的唯一方法是使用Firestore REST API。
是的,来自REST API的响应有点“繁琐”的格式,但提取字段值并不难,您只需要知道不同字段的类型并处理响应中某些字段不存在的情况。
请注意,这个答案也适用于Client SDKs:如果您不能从客户端应用程序使用Client SDK,您必须使用REST API。Admin和Client SDK在REST API的基础上添加了一层,使其更容易使用。
英文:
I understand that you use a server that cannot support one of the Firestore Admin SDKs.
AFAIK the only way to interact from your server with a Firestore Database apart from using the Admin SDK is by using the Firestore REST API.
Yes the responses from the REST APIs have somehow a "cumbersome" format but it is not that difficult to extract the field values, you just need to know the types of the different fields and manage the cases where some fields are not present in the response.
Note that this answer is also valid for the Client SDKs: If you cannot use a Client SDK from a client app, you have to use the REST API. The Admin and Client SDKs add a layer on top of the REST API which makes it much easier to use.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论