0

I am trying to create multiple node updates inside one Database.database().reference().updateChildValues([AnyHashable: Any]) request, but in this array I need key values which are just like childByAutoId().

I tried doing so by creating key nodes with the value of NSDate.timeIntervalSinceReferenceDate * 1000; but Firebase does not accept integer keys.

Is there a way to get the method of how Firebase creates these unique child nodes, which are time-sorted ID's?

Dexter
  • 2,462
  • 4
  • 24
  • 28
Devxln
  • 556
  • 6
  • 18
  • Possible duplicate of [Convert Int to String in Swift](https://stackoverflow.com/questions/24161336/convert-int-to-string-in-swift) – Tamás Sengel Mar 28 '19 at 15:35
  • Generally speaking (very generally), updateChildValues would be used when the node (key) is known so you know which node to update. The question sounds like you are creating nodes instead of updating them? Perhaps you can clarify the question and provide a snippet of your structure (as text please) so we can understand what's being asked? Also, timestamps for keys may not be the best idea - but again, need to understand the use case. – Jay Mar 28 '19 at 21:02
  • @Jay I am updating an known node, but with an dictionary with some unknown nodes. I am just trying to get firebase's method of generating the `childByAutoId()` key. – Devxln Mar 28 '19 at 22:27
  • Can you please include your Firebase structure? What do you propose it looks like? Also, can you post the code you've tried - `[AnyHashable: Any]` is too vague to understand the use case. Please review the following two guides on asking questions: [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask) and [How to create a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve). Update the question and we'll take a look! – Jay Mar 28 '19 at 22:45

1 Answers1

0
let uuid = UUID().uuidString
print(uuid)

Only create unique string

Hen Shabat
  • 519
  • 1
  • 6
  • 19