Пример #1
0
// More of a 'CreateFlight' - may cause dupes ...
func (db *FlightDB) PersistFlight(f f.Flight, gestationLog string) error {
	rootKey := datastore.NewKey(db.C, kFlightKind, "foo", 0, nil)
	key := datastore.NewIncompleteKey(db.C, kFlightKind, rootKey)

	if ff, err := f.Freeze(); err != nil {
		return err
	} else {
		ff.GestationLog = gestationLog + fmt.Sprintf("* datastore.Put: %s\n", time.Now().UTC())
		_, err = datastore.Put(db.C, key, ff)
		return err
	}
}
Пример #2
0
func (db *FlightDB) UpdateFlight(f f.Flight) error {
	key, err := datastore.DecodeKey(f.DatastoreKey())
	if err != nil {
		return err
	}

	if ff, err := f.Freeze(); err != nil {
		return err
	} else {
		ff.GestationLog = fmt.Sprintf("* datastore.Update: %s\n", time.Now().UTC())
		_, err = datastore.Put(db.C, key, ff)
		return err
	}
}