Ralf
Ralf

Reputation: 2632

Go datastore query for getting a single entity?

The Datastore API reference for Go has a GetAll function that returns a slice of entities. Isn't there a method that just returns the first entity found instead of a list?

Upvotes: 3

Views: 657

Answers (1)

Peter Knego
Peter Knego

Reputation: 80330

GetAll executes a query that returns all entities that match query conditions. If you want to return just one, set Limit(limit int) to 1.

Upvotes: 6

Related Questions