user2452723
user2452723

Reputation: 73

Spring GCP Datastore interface: setting the namespace?

I want to save an entity into Google Datastore using the Spring DatastoreOperations interface (com.google.cloud.spring.data.datastore.core.DatastoreTemplate.save() method). However, I also need to specify the datastore namespace, as I my data is stored in a separate namespace for each user. Is this at all possible using the Spring abstraction? It works when I hardcode the namespace in application.properties (spring.cloud.gcp.datastore.namespace=...) but obviously I need to set it at runtime depending on the request.

Upvotes: 0

Views: 414

Answers (1)

user2452723
user2452723

Reputation: 73

Ok, I think I found the solution: implementing a bean of type DatastoreNamespaceProvider seems to address exactly this need.

Upvotes: 1

Related Questions