func (d *DatastoreDatabase) StoreJob(job *Job) (string, error) {
	if _, err := d.GetJob(job.ID); err == nil {
		return "", errors.New("job already exists")
	}
	ctx := context.Background()
	key := newNameKeyWithNamespace(d.kind, job.ID, d.namespace)
	_, err := d.client.Put(ctx, key, job)
	if err != nil {
		return "", err
	}
	return job.ID, nil
}
StoreJob stores a job
package database
import (
	"context"
	"errors"
	"cloud.google.com/go/datastore"
)
const (
	entityKind      string = "Jobs"
	entityNamespace string = "captions-jobs"
)
type DatastoreClient interface {
	Put(context.Context, *datastore.Key, interface{}) (*datastore.Key, error)
	Get(context.Context, *datastore.Key, interface{}) error
	Delete(context.Context, *datastore.Key) error
	GetAll(context.Context, *datastore.Query, interface{}) ([]*datastore.Key, error)
}
type DatastoreDatabase struct {
	client    DatastoreClient
	kind      string
	namespace string
}
func NewDatastoreDatabase(projectID string) (*DatastoreDatabase, error) {
	ctx := context.Background()
	client, err := datastore.NewClient(ctx, projectID)
	if err != nil {
		return nil, err
	}
	return &DatastoreDatabase{
		client,
		entityKind,
		entityNamespace,
	}, nil
}