0

As the title suggested, can I post with the: https://firestore.googleapis.com/v1beta1/{database}/documents.commit command a single JSON file directly in my Firestore database and will they be processed? Added to the collections etc? Or should I go with POST projects.databases.documents.createDocument. I was reading this documentation I want to put json files from different sources in to my Firestore database to build up my collection. And where should I put the filename of the json file that I want to upload? Thanks!!

Iñigo
  • 2,500
  • 2
  • 10
  • 20
martend
  • 51
  • 1
  • 9
  • It isn't clear what you're trying to do, could you rephrase the question to make it more readable? What are you using GCloud or Firebase? Anyway, you can see [here](https://developers.google.com/apis-explorer/#search/firestore/firestore/v1beta1/) that `documments.commit` is for " Commits a transaction, while optionally updating documents." and `documents.createDocument` "documents.createDocument". For the JSON you need to send a POST request , see this [question](https://stackoverflow.com/questions/7172784/how-to-post-json-data-with-curl-from-terminal-commandline-to-test-spring-rest) – Iñigo Aug 15 '18 at 11:08
  • Thanks for the edit and answer, As of usage, the answer will be both in my understanding, with GCP I build the general backend, then use the firebase functionality and firestore db what interacts with my specific mobile app. Say the backend has a database with stamps from all over the world, that stamp collection needs to be updated etc. Then we have a stampcollecter who only is interested in Stamps from the UK, So to speed things up, the mobile app gets his on firestore db with only stamps from the UK. Maybe I overthink it and I just should use only firestore for everything :( – martend Aug 15 '18 at 12:04
  • No problem :D . But I still don't understand the question, sorry. Are you asking about what API call you should use (i.e `.commit` or `.createDocument`) and how to use the JSON? If so, did my comment help you? – Iñigo Aug 15 '18 at 13:21
  • Yes, your comment did help me, points for you! :) Maybe I should slow down a bit and not try to read the whole manual in a day :) I was kinda expecting that the UI of Firestore would have more functions build in. Create a database and have options on how to fill it with data, by upload from pc at home, aws, or by an external api. Now you have to code first to get things moved in to that database. Anyways Thanks again! – martend Aug 15 '18 at 19:33
  • I'm going to post my comment as an answer, so if someone has the same doubt as you they can read it more easily. I'm also gonna add some more info about your last comment. Feel free to accept and/or upvote my answer if you consider it helpful. – Iñigo Aug 16 '18 at 07:28

1 Answers1

1

You can see here [1] the usage of both calls:

  • documents.commit= Commits a transaction, while optionally updating documents
  • documents.createDocument= Creates a new document

For using the JSON in the API call you need to send a POST request, check this question [2].

Also, regarding your last comment, you can start collections and add documents using the Firestore UI, but also you can do that using client libraries in different languages (Python, Java, Go...). Here is a list of "How to"s regarding Firestore [3].

In case you think that some features are missing, you can always file a Feature Request following this link [4] (as Firestore is still not there, I would choose Datastore), but keep in mind that Firestore is still in Beta.

Iñigo
  • 2,500
  • 2
  • 10
  • 20
  • 1
    Accepted and voted, Thanks! That Firestore is in Beta is no problem, I want to discover, learn and create, so I consider myself to be in Beta as well :-) – martend Aug 16 '18 at 11:36