2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

pythonでfirestoreのデータを更新するときにハイフンを含むフィールド名を使いたい場合

Posted at

前回も解決方法がわからなかって探し回ったので、簡単にgoogle検索でヒットするようにqiita記事を書く。
QiitaのSEOを間借り。

TL;DR

バッククォートで囲む!

db.collection('users').document('AAAAABBBBB').update({
   u"status.`xxxx-yyyyy-zzzz`": "hogehoge"
})

解説

いつものノリで下のようなコード書くと詰む。

db.collection('users').document('AAAAABBBBB').update({
   u"status.xxxx-yyyyy-zzzz": "hogehoge"
})
ValueError: Non-alphanum char in element with leading alpha: xxxx-yyyyy-zzzz

参考

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?