Home>

Developed without a storyboard.

What i am doing

The content stored in the firestore is set to dictionary and used when setData is used.

Set and register like the following code.
"hoby"is still empty.
"registerDay": NSDate () is treated as"the date and time the user registered" ;, so
I only set the value once and I don't want to set it in the future.

db.collection ("users"). document (random ID) .setData (
            ["name": "taro",
             "registerDay": NSDate ()
, "Hoby": ""]


I want to ask you how to set NSDate ().

Things I want to do

Since"hoby"is empty, suppose you set the value to"illustration" ;.
At that time, nothing is entered in the value of"registerDay" ;: (because there is no change), but
If it is empty, an error will occur and it will be duplicated again with NSDate ().
Because it is not a String type, you cannot enter "quote".

I would like to ask you what value to enter in this case.

  • Answer # 1

      

    "registerDay": NSDate () treats it as"the date and time when the user registered.

      

    Since"hoby"is empty, suppose you set the value to"illustration" ;.

    What if you useupdateDataif you want to register some fields first and update them later?

    db.collection ("users"). document (random ID) .updateData ([
        "hoby": "Illustration"
    ])