저는 모델링에 대한 Google 워드 프로세서를 읽었습니다. (btw는 파이썬과 GAE/webapp2의 초보자입니다.) 관계를 통해 이렇게하는 것이 훨씬 쉬울 것이지만 데이터 저장소 및/또는 ndb와 함께 Google 앱 엔진을 배우려고합니다.App Engine 및 모델과 Python과의 관계
시도 : 여러 구역이있는 집이 있으며 각 구역에는 판독 값을 받아 서버로 보내는 센서 그룹 (빛, 습도, tmp)이 있습니다. 이 같은
뭔가 :
Class User(db.Model):
user = db.UserProperty()
usertype = db.StringProperty()(aka mom/father/child)
class Home(db.Model):
zone = db.IntegerProperty() #Zones in home unique int
zonename = db.StringProperty() # optional name for the zone
class Zone(db. Model):
sensortype = db. key or name? # I'd like to model moisture/tmp/light sensors that will be hereSensors in zone (from class sensors ?)
SensorID = #Ideally a key for that sensor in the zone ?
DateCreated = db.DateProperty()
class Sensors(db.Model): # this will get the actual readings when they come in
Sensortype (moisture, tmp, light)
timeReading = db.DateProperty()
Reading = db.FloatProperty()
나중에 내가 많은 센서 또는 개별 센서 (모든 영역 또는 개별 영역에서) 모든 온도 측정 값을 읽을 수됩니다에. 날짜/시간순으로 정렬 할 수 있어야합니다. 나는이 수치들을 일기 예보와 비교할 것이다.
Structured 개체, 부모/조상이있는 키 또는 ReferenceProperty를 사용해야하는지 여부를 파악하는 데 문제가 있습니다.
어디서부터 시작해야할까요? 나는 이것을 가장 잘 모델링하는 데에 손실이있다.
미리 도움을 청하십시오.
가능한 중복 [구글 앱 엔진에서 조상 또는 참조 속성을 사용?] (http://stackoverflow.com/questions/12123511/using-ancestors-or-reference-properties -in-google-app-engine) – dragonx
구체적인 예에서는 존 및 존 및 조상 센서의 조상과 조상을 만들고 이들 사이에 참조 속성이 전혀 없을 것입니다. 센서는 공간, 구역 및 가정의 구역에 고정되어 있습니다. 그 패턴을 액세스하는 데 맞게 귀하의 모델을 조정했다. 내 2c ;-) –
응답 해 주셔서 감사합니다. 나는 같은 것을 생각하고 있었지만 확인을 원했다. 센서/영역 또는 아니요에 대해 StructuredProperty를 사용하는 것이 합리적입니까? https://developers.google.com/appengine/docs/python/ndb/properties#computed – prussiap