I have News entity like this : 


type News struct {

Alias         string    `datastore:"alias"`

Title         string    `datastore:"title,noindex"`

Description   string    `datastore:"description,noindex"`

Content       string    `datastore:"content,noindex"` 

}


In database, "Alias" field is a primary key. Below is my query to get list 
News :


q = datastore.NewQuery("News").Limit(10)

listNews := make([]entity.News, 0, 10)

if _, err := q.GetAll(context, &listNews); err != nil {

        http.Error(rs, err.Error(), http.StatusInternalServerError)

return

}


Problem is i can't get Alias field from return results : 


for i := 0; i < len(listNews); i++ {

      fmt.Println(listNews[i].Alias) // print nothing

}


Now, i'm trying to put datastore key to return result by this way (not a 
good way, i think) : 


keys, err := q.GetAll(context, &listNews)

if err != nil {

http.Error(rs, err.Error(), http.StatusInternalServerError)

return

} 

for i := 0; i < len(listNews); i++ {

listNews[i].Alias = (&keys[i]).StringID()

        fmt.Println(listNews[i].Alias)

}


Is there another way to get list result with keys ("Alias" field in my 
case) ? Sorry if my english is not good and thank for reading.

-- 
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 http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/d/optout.

Reply via email to