Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make composite string property in Google App Engine?
    primarykey
    data
    text
    <p>I'm building an app where there are some events stored in the datastore, the model is (simplified) as follows: </p> <pre><code>class Event(db.Model) plan = db.ReferenceProperty(Plan) points = db.FloatProperty() date = db.DateTimeProperty() cumelativePoints = db.FloatProperty() </code></pre> <p>where Plan is the parent instance that group events to a user. My challenges are that (a) I need a consistence sort order since the sum of score of events before this event is stored in the event (b) multiple events can occur at the same time (c) the date can change (i.e., the order of the events changes) </p> <p>In <a href="https://sites.google.com/site/io/building-scalable-web-applications-with-google-app-engine" rel="nofollow">Building Scalable Web Applications with Google App Engine</a> (slide 36) a composite string property is suggested. My question is therefore how can it be implemented? I have two suggestions:</p> <ol> <li><p>Make an extra string property in the model (call it index) and a counter in plan, the new property is therefore (in psudo) <code>self.index = self.date.tostring+"|"+self.plan.counter</code>? When query order by index and when updating the date update index.</p></li> <li><p>Make an incremental counter in the model (e.g., <code>self.i</code>) and when sorting, order first by the counter (<code>i</code>) and then by date; in total <code>.order("i").order("date")</code>.</p></li> </ol> <p>Which is best or is there another solution that is better?</p> <p>Answers are highly appreciated! Sorry for the sloppy notation, bad english and all extra details from the project!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload