Dear Anons,
First of all thank you for the replies, your care is greatly, greatly
appreciated!
> # one item into ndb
> apple_count = len(Fruit.query().fetch(100))
> self.assertEqual(apple_count, 1)
>
After reading this, I've realised that fruits analogy is a wrong example of
the actual issue I am facing.
I would like to kindly request for some time to read this post.
I'm working on a server project for a petrol station company.
I have this station class.
class Station(modelpy.Model):
shifts = ndb.JsonProperty()
The Station's key's id is the name of a station.
Here are the names of the actual stations: "West Coast", "Woodlands",
"South View".
I use these station names in get_by_id() to get the station entity.
As you can see, Station consists of a JsonProperty called "shifts".
The "shifts" consists of the data as follows (shown in a json format):
{
"South View": {
"shifts": {
"Full Day": {
"start": "7am",
"end": "7pm"
}
}
},
"West Coast": {
"shifts": {
"Morning Shift": {
"start": "10am",
"end": "10pm"
},
"Night Shift": {
"start": "10pm",
"end": "10am"
}
}
},
"Woodlands": {
"shifts": {
"Morning Shift": {
"start": "8am",
"end": "8pm"
},
"Night Shift": {
"start": "8pm",
"end": "8am"
}
}
}
}
I need a solution for these 3:
1) Ndb must not be allowed to store more than 1 shift (e.g. key.put()
replaces any (if existing) entity with equal id).
2) Ndb must contain the "start" and "end" required property for every shift
(e.g. required=True).
3) Most IMPORTANT: A MAINTAINTABLE solution that does not need to be
re-implemented for other similar examples. (e.g. NOT write custom assertion
every single time!)
JsonProperty demands a crap-ton of maintainability
I don't want to write a custom assertion every time, instead I want a
generic solution (dictionary).
Don't mind the caps, I'm not shouting at anyone, just emphasis.
Love,
Ryan
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-appengine/d877b6c6-c7ed-412c-924b-c68759a6f8f1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.