Skip to content

Add support for namespaces #1

Description

@jgeewax

These exist to an extent but aren't universal and certainly not well documented.

There are two options:

  1. Create an object to manage namespaces
fromgcloudimportdatastoredataset=datastore.get_dataset(...)
namespace=dataset.namespace('my-namespace')
person=namespace.entity('Person')
person['name'] ='JJ'person.save()
query=namespace.query('Person')
printquery.fetch()
  1. Allow users to pass a namespace argument to various constructors (and set namespaces with a method, akin to setting a kind or id on a Key).
fromgcloudimportdatastoredataset=datastore.get_dataset(...)
person=dataset.entity('Person')
person.namespace('my-namespace')
person['name'] ='JJ'person.save()
query=dataset.query('Person').namespace('my-namespace')
printquery.fetch()

or

person=namespace.entity('Person')
person['name'] ='JJ'person.save(namespace='my-namespace')

I currently prefer option 2, where a namespace isn't a separate level in the hierarchy, but simply a flag passed around on queries or entities.

Metadata

Metadata

Assignees

Labels

api: datastoreIssues related to the Datastore API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions