Skip to content

bigfunctions > export_to_datastore

export_to_datastore

Signature

export_to_datastore(project, namespace, kind, key, data)

Description

Exports data to Datastore (Firestore in Datastore mode).

(💡 For this to work, 749389685934-compute@developer.gserviceaccount.com must have datastore user role in your project.)

Param Possible values
project Google Cloud project hosting the Datastore data. Should be unique for one query
namespace A namespace is like a dataset / a folder. It has many kinds which are like tables. If namespaceis null, default namespace will be used.
kind kind is like a table: a set of similar objects. Cannot be null.
key Unique identifier where data is stored inside kind. Can be an integer represented as a string (key is then named id in Datastore) or any string (key is named name in Datastore). If null a integer key (represented as string) will be generated.
data A json dict of data

Examples

1. Export data to default namespace with auto-generated key.

select bigfunctions.eu.export_to_datastore('your-project', null, 'user', null, json '{"name": "Marc Harris", "email": "marc@harris.com"}')
select bigfunctions.us.export_to_datastore('your-project', null, 'user', null, json '{"name": "Marc Harris", "email": "marc@harris.com"}')
select bigfunctions.europe_west1.export_to_datastore('your-project', null, 'user', null, json '{"name": "Marc Harris", "email": "marc@harris.com"}')
+------------------+
| key              |
+------------------+
| 4503604769587200 |
+------------------+

2. Export data to default namespace, with email as key.

select bigfunctions.eu.export_to_datastore('your-project', null, 'user', 'marc@harris.com', json '{"name": "Marc Harris"}')
select bigfunctions.us.export_to_datastore('your-project', null, 'user', 'marc@harris.com', json '{"name": "Marc Harris"}')
select bigfunctions.europe_west1.export_to_datastore('your-project', null, 'user', 'marc@harris.com', json '{"name": "Marc Harris"}')
+-----------------+
| key             |
+-----------------+
| marc@harris.com |
+-----------------+