Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9074071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:33:24+00:00 2026-06-16T18:33:24+00:00

I have an app using Go with this entity: type Product struct { Name

  • 0

I have an app using Go with this entity:

type Product struct {
  Name string
  Related []*datastore.Key
}

Is this possible to find all products that are related with a given key?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T18:33:26+00:00Added an answer on June 16, 2026 at 6:33 pm

    Is this possible to find all products that related with a given key?

    As you’re storing a slice of keys, this is not possible without retrieving all entities.

    However, you could create a new kind (RelatedProducts) which stores the related products (using the product as parent key).

    Example (Not tested)

    type Product struct {
        Name string
    }
    type RelatedProducts struct { // We store the the OriginalProduct as parent, so it is not needed as a property
        Related *datastore.Key
    }
    
    // Create a new relation
    func newRelation(c appengine.Context, productKey *datastore.Key, relatedProduct *datastore.Key) {
        key := datastore.NewIncompleteKey(c, "RelatedProducts", productKey)
        datastore.Put(c, key, &RelatedProduct{Related: relatedProduct})
    }
    
    // Get all related products
    func getAllRelatedProducts(c appengine.Context, productKey *datastore.Key) []*datastore.Key{
        var relatedProducts []RelatedProducts
    
        // Query the relations
        query := datastore.NewQuery("RelatedProducts").Ancestor(productKey)
        query.GetAll(c, &relatedProducts)
    
        // Loop over relatedProducts and append the data to keys 
        var keys []*datastore.Key
        for i := range relatedProducts {
            keys = append(keys, relatedProducts[i].Related)
        }
    
        return keys
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this iPad app using Storyboard. There are some file that are marked
Suppose I am building an app using current mysql database tables. I have this
So, I have this desktop app built using WPF and C#. It's basically an
I have an ASP.NET MVC 3 app hosted on IIS. This app is using
I have this RoR app that calls to RAILS_ROOT. When running it using rails
I have a facebook app that I authenticate using a general-purpose authentification. Like this:
I have written a BlackBerry app that RSA encrypts a message using PKCS1FormatterEngine. This
am using the application in this link http://www.jeasyui.com/tutorial/app/crud2.php .I have added one more column
I'm using Expressjs w/ node.js and I have a route like this: users.init(app.db, function()
I'm using the javascript module pattern, and have this so far: var APP; if(APP

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.