Firestore: save document reference or document id? [closed] - firebase

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 months ago.
Improve this question
I try to link a document to another document in my database. As far as I understand, I can save the ID or a reference to it.
What's the difference between those methods and which one suits me better?

A simple string document ID has no context while a Reference contains the entire path to a document. For the ease of use in a custom objects it will be useful to have the entire Reference object stored.
When writing queries you can also filter on a Reference object in the database by comparing it to another.
However, it's a personal preference. Anything that a string can do, Reference can also provide. Having a Reference type can saves you for trouble of building a new Reference object in your code and you can also use it in security rules for the same purpose when it comes time to use get() to fetch another document referenced by a field.

Related

Realtime database: how to add data from one reference to another reference? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 months ago.
Improve this question
How add this -N8O6lC8cGgMfLE_8BIR data from the reference Colis Futur to reference Colis Requetes
Here's what should happen. just below
If you want to copy a RTDB node from one parent node to the another one, you need to first read it from the source parent node and then write the node (it's value + key) under the parent target node.
How to do that depends on your exact techno/functional requirements. You could do that from your front end, if for example you app is a "Colis" management app or you could do that in the back-end with a Cloud Function, for example if you want to denormalize your data according to the NoSQL "philosophy".

Is there a way delete an item inside an array which is stored in firestore collection without using its document id? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I am making a todo list with React and firebase, I have placed a delete button beside every item . Is there a way to delete the item without having to fetch its document id?
You can't make any changes at all to any document without knowing its ID. The APIs for updating documents require that you provide a DocumentReference, and the only way you can build a DocumentReference is using a document ID.
If you don't know the document ID, you will have to query the collection, iterate the results, and somehow locate the document you're looking for.

Ensuring data integrity of Firestore exports [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I followed the following guide to set up automated imports and exports for my firestore database:
https://firebase.google.com/docs/firestore/solutions/schedule-export
However, the docs specify that
An export may include changes made while the operation was running.
Are batched transactions safe, or should I disable write access while a export is taking place?
There's nothing "unsafe" about the exports. You just have to realize that you don't get a guarantee about the contents of the export, given that the export doesn't represent a snapshot in time of the entire database. The database could be changing over time while the export happens, and the contents of all of the documents don't necessarily come from the point in time when you initiated the export. It's not possible to change this behavior. Your best bet is to simply lock down access to the database while the export is happening so you can guarantee for yourself some sort of consistency.
As such, exports are not suitable for what many people would consider a "backup". It's merely a convenience for you to save and load the contents of a database without having to write code.

Two Document having same documentId in Cloud Firestore [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I have root collection, inside that two documents having the same Document Id. The first document having data and the second is in italic format. On click of the second document, it will navigate to an error page saying that the project does not exist or either you do not have permission. Attaching a screenshot for reference.
It showing two document with the same DocumentId first in normal case and second in Italic. "Maharashtra", "Maharashtra".
At some point in the past, you have deleted the document "Maharashtra" without recursively deleting it's child collections.
These collections are still present in your database but not currently attached to the parent document. As an example, the document "/states/Maharashtra/logs/day1" might exist with data, while it's parent collection "/states/Maharashtra/logs" is not a part of the current document "/states/Maharashtra".
You should be able to expand the italicised entry to see it's orphaned sub-collections.
#puf explained it better here.

What is the "best" method for saving games in XNA? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I have been struggling with finding a good method for storing save game data in XNA.
What would be a good method to go about saving game information that is encrypted and not easily readable/editable by others?
I usually like Json but because you don't want it readable, you should use a binary serializer. Note that with binary serialization, new saves are not reverse compatible with older saves because the serialization and deserialization process follow a strict structure and is invalidated as soon as changes are made to it. You can then encrypt your binary save file using Rijndael or something like that.

Resources