1414
1515'use strict' ;
1616
17- const { Datastore} = require ( '@google-cloud/datastore' ) ;
17+ import { Datastore } from '@google-cloud/datastore' ;
1818
1919// Instantiates a client
2020const datastore = new Datastore ( ) ;
@@ -58,7 +58,7 @@ const getKeyFromRequestData = requestData => {
5858 * @param {object } req.body.value Value to save to Cloud Datastore, e.g. {"description":"Buy milk"}
5959 * @param {object } res Cloud Function response context.
6060 */
61- exports . set = async ( req , res ) => {
61+ export async function set ( req , res ) {
6262 // The value contains a JSON document representing the entity we want to save
6363 if ( ! req . body . value ) {
6464 const err = makeErrorObj ( 'Value' ) ;
@@ -80,7 +80,7 @@ exports.set = async (req, res) => {
8080 console . error ( new Error ( err . message ) ) ; // Add to Stackdriver Error Reporting
8181 res . status ( 500 ) . send ( err . message ) ;
8282 }
83- } ;
83+ }
8484
8585/**
8686 * Retrieves a record.
@@ -94,7 +94,7 @@ exports.set = async (req, res) => {
9494 * @param {string } req.body.key Key at which to retrieve the data, e.g. "sampletask1".
9595 * @param {object } res Cloud Function response context.
9696 */
97- exports . get = async ( req , res ) => {
97+ export async function get ( req , res ) {
9898 try {
9999 const key = await getKeyFromRequestData ( req . body ) ;
100100 const [ entity ] = await datastore . get ( key ) ;
@@ -110,7 +110,7 @@ exports.get = async (req, res) => {
110110 console . error ( new Error ( err . message ) ) ; // Add to Stackdriver Error Reporting
111111 res . status ( 500 ) . send ( err . message ) ;
112112 }
113- } ;
113+ }
114114
115115/**
116116 * Deletes a record.
@@ -124,7 +124,7 @@ exports.get = async (req, res) => {
124124 * @param {string } req.body.key Key at which to delete data, e.g. "sampletask1".
125125 * @param {object } res Cloud Function response context.
126126 */
127- exports . del = async ( req , res ) => {
127+ export async function del ( req , res ) {
128128 // Deletes the entity
129129 // The delete operation will not fail for a non-existent entity, it just
130130 // doesn't delete anything
@@ -136,4 +136,4 @@ exports.del = async (req, res) => {
136136 console . error ( new Error ( err . message ) ) ; // Add to Stackdriver Error Reporting
137137 res . status ( 500 ) . send ( err . message ) ;
138138 }
139- } ;
139+ }
0 commit comments