1

I have a entity EmergencyCase that has 2 embedded structs (1 array and 1 struct) When I try to save the EmergencyCase by calling:

datastore.Put(c, key, &ec)

Everything is stored fine except the Pos field (type Position). There is no error or log entry about this. It is just not stored. Any suggestions?

Here are my 3 entities definitions:

type Position struct{
    lon float32
    lat float32
}
type EmergencyCase struct{
    // Autogenerated id, not stored in the database.
    ID string `datastore:"-"`
    CreatedAt time.Time
    Closed bool
    ClosedByUser bool `datastore:",noindex"`
    AutoClosed bool `datastore:",noindex"`
    Pos Position
    Events []Event
}

type Event struct{
    // Autogenerated id, not stored in the datastore.
    ID string `datastore:"-"`
    CreatedAt time.Time
    Name string `datastore:",noindex"`
}
2
  • you won't have a Pos field in the datastore, but you will have lon / lat fields .. is that the case ? Commented Nov 8, 2015 at 13:07
  • No that was not the case. Commented Nov 9, 2015 at 8:09

2 Answers 2

5

Export the Position field names by uppercasing the first letter in the name. The datastore stores exported fields only.

type Position struct{
  Lon float32
  Lat float32
}
Sign up to request clarification or add additional context in comments.

1 Comment

That was the mistake. Thank you
1

Try using appengine.GeoPoint as an altenative/optimised class

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.