Google App Engine - Datastore get_or_insert key_name confusion

后端 未结 2 995
[愿得一人]
[愿得一人] 2021-01-06 04:34

I am confused by get_or_insert(..). What should I pass as the key_name? Consider the following example:

class Person(db.model)
             


        
2条回答
  •  自闭症患者
    2021-01-06 04:55

    You can think of key_name like a primary key. Look at the docs for get_or_insert(...), there is an example of what the back-end code looks like.

    If name is a unique field, you might want to use that as the key name too. Although I would suggest stripping white-space and normalizing case.

提交回复
热议问题