keyProperty
时间: 2023-10-10 17:09:44 浏览: 58
KeyProperty is a property in Google Cloud Datastore, which is used to represent the key of the entity. It is defined as a property that is used to uniquely identify an entity in the datastore. The KeyProperty is used to store the key of the entity in the datastore and can be used to retrieve the entity later.
For example, if you have an entity called "Person" in the datastore, the KeyProperty would be used to store the key of the Person entity. This would allow you to retrieve the entity later by using the key as a reference.
In Python, the KeyProperty is defined using the ndb.KeyProperty() function. Here is an example:
```
from google.cloud import ndb
class Person(ndb.Model):
name = ndb.StringProperty()
age = ndb.IntegerProperty()
key_prop = ndb.KeyProperty()
```
In this example, the KeyProperty is defined as "key_prop". This property will store the key of the Person entity in the datastore.
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)