Skip to content

Commit

Permalink
docs: simplify samples
Browse files Browse the repository at this point in the history
  • Loading branch information
olavloite committed May 17, 2021
1 parent 806af9e commit 52b8cf5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 53 deletions.
4 changes: 2 additions & 2 deletions samples/json-query-parameter.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ async function queryWithJsonParameter(instanceId, databaseId, projectId) {
type: 'json',
};

const jsonValue = {rating: 9, description: 'This is a nice place'};
const jsonValue = {rating: 9};

const query = {
sql: `SELECT VenueId, VenueDetails FROM Venues
WHERE JSON_VALUE(VenueDetails, '$.description') = JSON_VALUE(@details, '$.description')`,
WHERE JSON_VALUE(VenueDetails, '$.rating') = JSON_VALUE(@details, '$.rating')`,
params: {
details: jsonValue,
},
Expand Down
62 changes: 11 additions & 51 deletions samples/json-update-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async function updateWithJsonData(instanceId, databaseId, projectId) {
const data = [
{
VenueId: '19',
VenueDetails: {rating: 9, description: 'This is a nice place'},
VenueDetails: {rating: 9, open: true},
LastUpdateTime: 'spanner.commit_timestamp()',
},
{
Expand All @@ -52,21 +52,17 @@ async function updateWithJsonData(instanceId, databaseId, projectId) {
// library would encode this value as ARRAY<JSON> instead of JSON.
VenueDetails: `[
{
"wing1": {
"description": "the first wing",
"size": "5"
}
"name": null,
"open": true
},
{
"wing2": {
"description": "the second wing",
"size": "10"
}
"name": "room 2",
"open": false
},
{
"main hall": {
"description": "this is the biggest space",
"size": "200"
"size": 200
}
}
]`,
Expand All @@ -75,48 +71,12 @@ async function updateWithJsonData(instanceId, databaseId, projectId) {
{
VenueId: '42',
VenueDetails: {
id: 'central123',
name: 'Central Park',
description: '🏞∮πρότερονแผ่นดินฮั่นเสื่อมሰማይᚻᛖ',
location: {
address: '59th St to 110th St',
crossStreet: '5th Ave to Central Park West',
lat: 40.78408342593807,
lng: -73.96485328674316,
postalCode: '10028',
cc: 'US',
city: 'New York',
state: 'NY',
country: 'United States',
formattedAddress: [
'59th St to 110th St (5th Ave to Central Park West)',
'New York, NY 10028',
'United States',
],
},
hours: {
status: 'Likely open',
isOpen: true,
isLocalHoliday: false,
timeframes: [
{
days: 'Tue–Thu',
open: [{time: 'Noon–8:00PM'}],
},
{
days: 'Fri',
open: [{time: '11:00 AM–7:00 PM'}],
},
{
days: 'Sat',
open: [{time: '8:00 AM–8:00PM'}],
},
{
days: 'Sun',
open: [{time: '8:00 AM–7:00 PM'}],
},
],
name: null,
open: {
Monday: true,
Tuesday: false,
},
tags: ['large', 'airy'],
},
LastUpdateTime: 'spanner.commit_timestamp()',
},
Expand Down

0 comments on commit 52b8cf5

Please sign in to comment.