const { support } = userData;
const res = fetch("https://j-kik-3f4e1-default-rtdb.firebaseio.com/userDataRecords.json",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
support,
})
}

- 79,263
- 10
- 95
- 121

- 1
- 8
-
What do you exactly mean by "**remov(ing)** the generated id" of a node of the Realtime Database? Can you show the desired result in a similar screenshot? – Renaud Tarnec Jul 31 '22 at 11:50
-
remove mean i dont want this id the data direct save in userdatarecords – Fahad Jul 31 '22 at 12:11
1 Answers
Generic approach for saving several similar values (i.e. same family of values) under a given node:
Usually, if you want to save several similar values (i.e. same family of values) under a given node without creating sub-nodes with an auto-generated key, I can see the two following options:
Option 1: Use the value as the node keys and assign them a dummy data (e.g. true
), as follows:
- parentNode
- value1: true
- value2: true
- value3: true
Option 2: Save the values with sub-node keys that you generate yourself. For example, keys that are numeric and sequential, as follows:
- userdatarecords
- 1: value1
- 2: value2
- 3: value3
Note that by doing this way, you will actually store the data as an Array and this is not recommended in most of the cases, see this official blog article.
Of course you could generate sub-node keys that are not numeric and/or sequential.
Specific case for saving URLs
As Puf mentioned in his comment below, dots are not allowed in RTDB keys. Therefore he advised to "use the URL's hash as the key, and then put the actual URL as its value". You can find a hash function in JavaScript in this SO answer.
therefore Option 1 above would become similar to an option 2 approach, as follows:
- userdatarecords
- 4340527707825375: https://www.abcd.com
- 6839177281380098: https://www.efgh.com
- 228613294339159: https://www.ijkl.com

- 79,263
- 10
- 95
- 121
-
1For option 1, keep in mind that dots are not allowed in RTDB keys, so you'll have to encode the URL to remove those. A common trick would be to use the URL's hash as the key, and then put the actual URL as its value. – Frank van Puffelen Jul 31 '22 at 14:51
-
@FrankvanPuffelen Thanks for the remark Puf! I've adapted the answer. – Renaud Tarnec Jul 31 '22 at 15:19
-
Sir i have a a q if i don't insert data and make update function so is it work because client wants to update data again and again never want to make any id – Fahad Aug 01 '22 at 05:32
-
Sorry, I’m not sure to understand your comment. You can modify your question and to more details on what you are trying to achieve. You can add a screenshot of the expected result. – Renaud Tarnec Aug 01 '22 at 06:23
-