From ae4514d63ca3b538bc03904ae8fc17c1c722b664 Mon Sep 17 00:00:00 2001 From: Vandanadevi Rajamani <70127005+Vandana-Rajamani@users.noreply.github.com> Date: Tue, 5 Mar 2024 15:56:24 +0530 Subject: [PATCH] New code examples for typescript (#162) * updated sample schemas * new typescript files --- SampleSchemas/AcctStreamSchema/acctstream.ddl | 7 + .../AcctStreamSchema/acctstreamData.json | 380 +++++ .../AcctStreamSchema/acctstream_loaddata.sql | 400 +---- SampleSchemas/BaggageSchema/baggageData.json | 1439 +++++++++++++++++ SampleSchemas/BaggageSchema/baggageInfo.ddl | 9 + .../BaggageSchema/baggageschema_loaddata.sql | 1425 +--------------- .../{ => javascript}/AddBagData.js | 0 .../sqlexamples/{ => javascript}/AddData.js | 0 .../{ => javascript}/AlterTable.js | 0 .../{ => javascript}/CreateTable.js | 0 .../{ => javascript}/GroupSortData.js | 0 .../sqlexamples/{ => javascript}/Indexes.js | 0 .../{ => javascript}/ModifyData.js | 0 .../{ => javascript}/MultiDataOps.js | 0 .../{ => javascript}/MultiWrite.js | 0 .../{ => javascript}/Namespaces.js | 0 .../sqlexamples/{ => javascript}/QueryData.js | 0 .../sqlexamples/{ => javascript}/Regions.js | 0 .../{ => javascript}/SQLExpressions.js | 0 .../{ => javascript}/SQLFunctions.js | 0 .../{ => javascript}/SQLOperators.js | 0 .../{ => javascript}/TableJoins.js | 0 .../sqlexamples/typescript/AddBagData.ts | 421 +++++ .../sqlexamples/typescript/AddData.ts | 364 +++++ .../sqlexamples/typescript/AlterTable.ts | 97 ++ .../sqlexamples/typescript/CreateTable.ts | 81 + .../sqlexamples/typescript/GroupSortData.ts | 453 ++++++ .../sqlexamples/typescript/Indexes.ts | 96 ++ .../sqlexamples/typescript/ModifyData.ts | 536 ++++++ .../sqlexamples/typescript/MultiDataOps.ts | 156 ++ .../sqlexamples/typescript/MultiWrite.ts | 168 ++ .../sqlexamples/typescript/Namespaces.ts | 64 + .../sqlexamples/typescript/QueryData.ts | 397 +++++ .../sqlexamples/typescript/Regions.ts | 97 ++ .../sqlexamples/typescript/SQLExpressions.ts | 475 ++++++ .../sqlexamples/typescript/SQLFunctions.ts | 465 ++++++ .../sqlexamples/typescript/SQLOperators.ts | 464 ++++++ .../sqlexamples/typescript/TableJoins.ts | 194 +++ 38 files changed, 6371 insertions(+), 1817 deletions(-) create mode 100644 SampleSchemas/AcctStreamSchema/acctstream.ddl create mode 100644 SampleSchemas/AcctStreamSchema/acctstreamData.json create mode 100644 SampleSchemas/BaggageSchema/baggageData.json create mode 100644 SampleSchemas/BaggageSchema/baggageInfo.ddl rename examples-nosql-node-sdk/sqlexamples/{ => javascript}/AddBagData.js (100%) rename examples-nosql-node-sdk/sqlexamples/{ => javascript}/AddData.js (100%) rename examples-nosql-node-sdk/sqlexamples/{ => javascript}/AlterTable.js (100%) rename examples-nosql-node-sdk/sqlexamples/{ => javascript}/CreateTable.js (100%) rename examples-nosql-node-sdk/sqlexamples/{ => javascript}/GroupSortData.js (100%) rename examples-nosql-node-sdk/sqlexamples/{ => javascript}/Indexes.js (100%) rename examples-nosql-node-sdk/sqlexamples/{ => javascript}/ModifyData.js (100%) rename examples-nosql-node-sdk/sqlexamples/{ => javascript}/MultiDataOps.js (100%) rename examples-nosql-node-sdk/sqlexamples/{ => javascript}/MultiWrite.js (100%) rename examples-nosql-node-sdk/sqlexamples/{ => javascript}/Namespaces.js (100%) rename examples-nosql-node-sdk/sqlexamples/{ => javascript}/QueryData.js (100%) rename examples-nosql-node-sdk/sqlexamples/{ => javascript}/Regions.js (100%) rename examples-nosql-node-sdk/sqlexamples/{ => javascript}/SQLExpressions.js (100%) rename examples-nosql-node-sdk/sqlexamples/{ => javascript}/SQLFunctions.js (100%) rename examples-nosql-node-sdk/sqlexamples/{ => javascript}/SQLOperators.js (100%) rename examples-nosql-node-sdk/sqlexamples/{ => javascript}/TableJoins.js (100%) create mode 100644 examples-nosql-node-sdk/sqlexamples/typescript/AddBagData.ts create mode 100644 examples-nosql-node-sdk/sqlexamples/typescript/AddData.ts create mode 100644 examples-nosql-node-sdk/sqlexamples/typescript/AlterTable.ts create mode 100644 examples-nosql-node-sdk/sqlexamples/typescript/CreateTable.ts create mode 100644 examples-nosql-node-sdk/sqlexamples/typescript/GroupSortData.ts create mode 100644 examples-nosql-node-sdk/sqlexamples/typescript/Indexes.ts create mode 100644 examples-nosql-node-sdk/sqlexamples/typescript/ModifyData.ts create mode 100644 examples-nosql-node-sdk/sqlexamples/typescript/MultiDataOps.ts create mode 100644 examples-nosql-node-sdk/sqlexamples/typescript/MultiWrite.ts create mode 100644 examples-nosql-node-sdk/sqlexamples/typescript/Namespaces.ts create mode 100644 examples-nosql-node-sdk/sqlexamples/typescript/QueryData.ts create mode 100644 examples-nosql-node-sdk/sqlexamples/typescript/Regions.ts create mode 100644 examples-nosql-node-sdk/sqlexamples/typescript/SQLExpressions.ts create mode 100644 examples-nosql-node-sdk/sqlexamples/typescript/SQLFunctions.ts create mode 100644 examples-nosql-node-sdk/sqlexamples/typescript/SQLOperators.ts create mode 100644 examples-nosql-node-sdk/sqlexamples/typescript/TableJoins.ts diff --git a/SampleSchemas/AcctStreamSchema/acctstream.ddl b/SampleSchemas/AcctStreamSchema/acctstream.ddl new file mode 100644 index 0000000..175d1fc --- /dev/null +++ b/SampleSchemas/AcctStreamSchema/acctstream.ddl @@ -0,0 +1,7 @@ +CREATE TABLE IF NOT EXISTS stream_acct( +acct_id INTEGER, +profile_name STRING, +account_expiry TIMESTAMP(9), +acct_data JSON, +PRIMARY KEY(acct_id) +); diff --git a/SampleSchemas/AcctStreamSchema/acctstreamData.json b/SampleSchemas/AcctStreamSchema/acctstreamData.json new file mode 100644 index 0000000..cf8cc63 --- /dev/null +++ b/SampleSchemas/AcctStreamSchema/acctstreamData.json @@ -0,0 +1,380 @@ +{ +"acct_id": 1, +"profile_name" : "AP", +"account_expiry" : "2023-10-18", +"acct_data": { + "firstName": "Adam", + "lastName": "Phillips", + "country": "Germany", + "contentStreamed": [ + { + "showName": "At the Ranch", + "showId": 26, + "showtype": "tvseries", + "genres": [ + "action", + "crime", + "spanish" + ], + "numSeasons": 4, + "seriesInfo": [ + { + "seasonNum": 1, + "numEpisodes": 2, + "episodes": [ + { + "episodeID": 20, + "episodeName": "Season 1 episode 1", + "lengthMin": 85, + "minWatched": 85, + "date": "2022-04-18" + }, + { + "episodeID": 30, + "lengthMin": 60, + "episodeName": "Season 1 episode 2", + "minWatched": 60, + "date": "2022-04-18" + } + ] + }, + { + "seasonNum": 2, + "numEpisodes": 2, + "episodes": [ + { + "episodeID": 40, + "episodeName": "Season 2 episode 1", + "lengthMin": 50, + "minWatched": 50, + "date": "2022-04-25" + }, + { + "episodeID": 50, + "episodeName": "Season 2 episode 2", + "lengthMin": 45, + "minWatched": 30, + "date": "2022-04-27" + } + ] + }, + { + "seasonNum": 3, + "numEpisodes": 2, + "episodes": [ + { + "episodeID": 60, + "episodeName": "Season 3 episode 1", + "lengthMin": 50, + "minWatched": 50, + "date": "2022-04-25" + }, + { + "episodeID": 70, + "episodeName": "Season 3 episode 2", + "lengthMin": 45, + "minWatched": 30, + "date": "2022-04-27" + } + ] + } + ] + }, + { + "showName": "Bienvenu", + "showId": 15, + "showtype": "tvseries", + "genres": [ + "comedy", + "french" + ], + "numSeasons": 2, + "seriesInfo": [ + { + "seasonNum": 1, + "numEpisodes": 2, + "episodes": [ + { + "episodeID": 20, + "episodeName": "Bonjour", + "lengthMin": 45, + "minWatched": 45, + "date": "2022-03-07" + }, + { + "episodeID": 30, + "episodeName": "Merci", + "lengthMin": 42, + "minWatched": 42, + "date": "2022-03-08" + } + ] + } + ] + } + ] } +} + +{ +"acct_id": 2, +"profile_name" : "AW", +"account_expiry" : "2023-12-18", +"acct_data": { + "firstName": "Adelaide", + "lastName": "Willard", + "country" : "France", + "contentStreamed": [ + { + "showName": "Bienvenu", + "showId": 15, + "showtype": "tvseries", + "genres" : ["comedy", "french"], + "numSeasons" : 2, + "seriesInfo": [ + { + "seasonNum" : 1, + "numEpisodes" : 2, + "episodes": [ + { + "episodeID": 20, + "lengthMin": 45, + "minWatched": 45, + "date": "2022-06-01" + }, + { + "episodeID": 30, + "lengthMin": 42, + "minWatched": 42, + "date": "2022-06-01" + } + ] + }, + { + "seasonNum": 2, + "numEpisodes" : 3, + "episodes": [ + { + "episodeID": 40, + "lengthMin": 50, + "minWatched": 50, + "date": "2022-06-01" + } + ] + } + ] + } + ] + } +} + +{ +"acct_id": 3, +"profile_name" : "DA", +"account_expiry" : "2023-12-31", +"acct_data": { + "firstName": "Dierdre", + "lastName": "Amador", + "country" : "USA", + "contentStreamed": [ + { + "showName": "Bienvenu", + "showId": 15, + "showtype": "tvseries", + "genres" : ["comedy", "french"], + "numSeasons" : 2, + "seriesInfo": [ + { + "seasonNum" : 1, + "numEpisodes" : 2, + "episodes": [ + { + "episodeID": 20, + "lengthMin": 45, + "minWatched": 44, + "date": "2022-05-19" + }, + { + "episodeID": 30, + "lengthMin": 42, + "minWatched": 42, + "date": "2022-05-19" + } + ] + }, + { + "seasonNum": 2, + "numEpisodes" : 3, + "episodes": [ + { + "episodeID": 40, + "lengthMin": 50, + "minWatched": 50, + "date": "2022-05-20" + }, + { + "episodeID": 50, + "lengthMin": 45, + "minWatched": 45, + "date": "2022-05-21" + } + ] + } + ] + }, + { + "showName": "Dane", + "showId": 16, + "showtype": "tvseries", + "genres" : ["comedy", "drama", "danish"], + "numSeasons" : 2, + "seriesInfo": [ + { + "seasonNum" : 1, + "numEpisodes" : 2, + "episodes": [ + { + "episodeID": 20, + "lengthMin": 65, + "minWatched": 65, + "date": "2022-03-18" + }, + { + "episodeID": 30, + "lengthMin": 60, + "minWatched": 60, + "date": "2022-03-19" + } + ] + }, + { + "seasonNum": 2, + "numEpisodes" : 2, + "episodes": [ + { + "episodeID": 40, + "lengthMin": 50, + "minWatched": 50, + "date": "2022-05-05" + }, + { + "episodeID": 50, + "lengthMin": 45, + "minWatched": 45, + "date": "2022-05-06" + } + ] + } + ] + } + ] + } +} + +{ +"acct_id": 4, +"profile_name" : "DM", +"account_expiry" : "2024-03-18", +"acct_data": { + "firstName" : "Doris", + "lastName" : "Martin", + "country" : "USA", + "contentStreamed": [ + { + "showName": "Bienvenu", + "showId": 15, + "showtype": "tvseries", + "genres" : ["comedy", "french"], + "numSeasons" : 2, + "seriesInfo": [ + { + "seasonNum" : 1, + "numEpisodes" : 2, + "episodes": [ + { + "episodeID": 20, + "lengthMin": 45, + "minWatched": 45, + "date": "2022-01-18" + }, + { + "episodeID": 30, + "lengthMin": 42, + "minWatched": 42, + "date": "2022-01-19" + } + ] + }, + { + "seasonNum": 2, + "numEpisodes" : 3, + "episodes": [ + { + "episodeID": 40, + "lengthMin": 50, + "minWatched": 50, + "date": "2022-02-18" + }, + { + "episodeID": 50, + "lengthMin": 45, + "minWatched": 45, + "date": "2022-02-28" + }, + { + "episodeID": 60, + "lengthMin": 55, + "minWatched": 55, + "date": "2022-04-02" + } + ] + } + ] + }, + { + "showName": "Dane", + "showId": 16, + "showtype": "tvseries", + "genres" : ["comedy", "drama", "danish"], + "numSeasons" : 2, + "seriesInfo": [ + { + "seasonNum" : 1, + "numEpisodes" : 2, + "episodes": [ + { + "episodeID": 20, + "lengthMin": 65, + "minWatched": 65, + "date": "2022-01-18" + }, + { + "episodeID": 30, + "lengthMin": 60, + "minWatched": 60, + "date": "2022-02-07" + } + ] + }, + { + "seasonNum": 2, + "numEpisodes" : 2, + "episodes": [ + { + "episodeID": 40, + "lengthMin": 50, + "minWatched": 50, + "date": "2022-02-08" + }, + { + "episodeID": 50, + "lengthMin": 45, + "minWatched": 45, + "date": "2022-02-20" + } + ] + } + ] + } + ] + } +} diff --git a/SampleSchemas/AcctStreamSchema/acctstream_loaddata.sql b/SampleSchemas/AcctStreamSchema/acctstream_loaddata.sql index eb545d3..1ff179d 100644 --- a/SampleSchemas/AcctStreamSchema/acctstream_loaddata.sql +++ b/SampleSchemas/AcctStreamSchema/acctstream_loaddata.sql @@ -1,396 +1,4 @@ -### CREATE table if not present ### -CREATE TABLE IF NOT EXISTS stream_acct( -acct_id INTEGER, -profile_name STRING, -account_expiry TIMESTAMP, -acct_data JSON, -PRIMARY KEY(acct_id) -); - -### row 1 ### -INSERT INTO stream_acct VALUES( -1, -"AP", -"2023-10-18", -{ - "firstName": "Adam", - "lastName": "Phillips", - "country" : "Germany", - "contentStreamed": [ - { - "showName" : "At the Ranch", - "showId" : 26, - "showtype" : "tvseries", - "genres" : ["action", "crime", "spanish"], - "numSeasons" : 4, - "seriesInfo": [ - { - "seasonNum" : 1, - "numEpisodes" : 2, - "episodes": [ - { - "episodeID": 20, - "episodeName" : "Season 1 episode 1", - "lengthMin": 85, - "minWatched": 85, - "date" : "2022-04-18" - }, - { - "episodeID": 30, - "lengthMin": 60, - "episodeName" : "Season 1 episode 2", - "minWatched": 60, - "date" : "2022-04-18" - } - ] - }, - { - "seasonNum": 2, - "numEpisodes" : 2, - "episodes": [ - { - "episodeID": 40, - "episodeName" : "Season 2 episode 1", - "lengthMin": 50, - "minWatched": 50, - "date" : "2022-04-25" - }, - { - "episodeID": 50, - "episodeName" : "Season 2 episode 2", - "lengthMin": 45, - "minWatched": 30, - "date" : "2022-04-27" - } - ] - } - ] - }, - { - "seasonNum": 3, - "numEpisodes" : 2, - "episodes": [ - { - "episodeID": 60, - "episodeName" : "Season 3 episode 1", - "lengthMin": 50, - "minWatched": 50, - "date" : "2022-04-25" - }, - { - "episodeID": 70, - "episodeName" : "Season 3 episode 2", - "lengthMin": 45, - "minWatched": 30, - "date" : "2022-04-27" - } - ] - } - ] - }, - { - "showName": "Bienvenu", - "showId": 15, - "showtype": "tvseries", - "genres" : ["comedy", "french"], - "numSeasons" : 2, - "seriesInfo": [ - { - "seasonNum" : 1, - "numEpisodes" : 2, - "episodes": [ - { - "episodeID": 20, - "episodeName" : "Bonjour", - "lengthMin": 45, - "minWatched": 45, - "date" : "2022-03-07" - }, - { - "episodeID": 30, - "episodeName" : "Merci", - "lengthMin": 42, - "minWatched": 42, - "date" : "2022-03-08" - } - ] - } - ] - } - ] - } -) -; - -### row 2 ### - -INSERT INTO stream_acct VALUES( -2, -"AW", -"2023-12-18", -{ - "firstName": "Adelaide", - "lastName": "Willard", - "country" : "France", - "contentStreamed": [ - { - "showName": "Bienvenu", - "showId": 15, - "showtype": "tvseries", - "genres" : ["comedy", "french"], - "numSeasons" : 2, - "seriesInfo": [ - { - "seasonNum" : 1, - "numEpisodes" : 2, - "episodes": [ - { - "episodeID": 20, - "lengthMin": 45, - "minWatched": 45, - "date": "2022-06-01" - }, - { - "episodeID": 30, - "lengthMin": 42, - "minWatched": 42, - "date": "2022-06-01" - } - ] - }, - { - "seasonNum": 2, - "numEpisodes" : 3, - "episodes": [ - { - "episodeID": 40, - "lengthMin": 50, - "minWatched": 50, - "date": "2022-06-01" - } - ] - } - ] - } - ] - } -) -; - -### row 3 ### - -INSERT INTO stream_acct VALUES( -3, -"DA", -"2023-12-31", -{ - "firstName": "Dierdre", - "lastName": "Amador", - "country" : "USA", - "contentStreamed": [ - { - "showName": "Bienvenu", - "showId": 15, - "showtype": "tvseries", - "genres" : ["comedy", "french"], - "numSeasons" : 2, - "seriesInfo": [ - { - "seasonNum" : 1, - "numEpisodes" : 2, - "episodes": [ - { - "episodeID": 20, - "lengthMin": 45, - "minWatched": 44, - "date": "2022-05-19" - }, - { - "episodeID": 30, - "lengthMin": 42, - "minWatched": 42, - "date": "2022-05-19" - } - ] - }, - { - "seasonNum": 2, - "numEpisodes" : 3, - "episodes": [ - { - "episodeID": 40, - "lengthMin": 50, - "minWatched": 50, - "date": "2022-05-20" - }, - { - "episodeID": 50, - "lengthMin": 45, - "minWatched": 45, - "date": "2022-05-21" - } - ] - } - ] - }, - { - "showName": "Dane", - "showId": 16, - "showtype": "tvseries", - "genres" : ["comedy", "drama", "danish"], - "numSeasons" : 2, - "seriesInfo": [ - { - "seasonNum" : 1, - "numEpisodes" : 2, - "episodes": [ - { - "episodeID": 20, - "lengthMin": 65, - "minWatched": 65, - "date": "2022-03-18" - }, - { - "episodeID": 30, - "lengthMin": 60, - "minWatched": 60, - "date": "2022-03-19" - } - ] - }, - { - "seasonNum": 2, - "numEpisodes" : 2, - "episodes": [ - { - "episodeID": 40, - "lengthMin": 50, - "minWatched": 50, - "date": "2022-05-05" - }, - { - "episodeID": 50, - "lengthMin": 45, - "minWatched": 45, - "date": "2022-05-06" - } - ] - } - ] - } - ] - } -) -; - -### row 4 ### - -INSERT INTO stream_acct VALUES( -4, -"DM", -"2024-03-18", -{ - "firstName" : "Doris", - "lastName" : "Martin", - "country" : "USA", - "contentStreamed": [ - { - "showName": "Bienvenu", - "showId": 15, - "showtype": "tvseries", - "genres" : ["comedy", "french"], - "numSeasons" : 2, - "seriesInfo": [ - { - "seasonNum" : 1, - "numEpisodes" : 2, - "episodes": [ - { - "episodeID": 20, - "lengthMin": 45, - "minWatched": 45, - "date": "2022-01-18" - }, - { - "episodeID": 30, - "lengthMin": 42, - "minWatched": 42, - "date": "2022-01-19" - } - ] - }, - { - "seasonNum": 2, - "numEpisodes" : 3, - "episodes": [ - { - "episodeID": 40, - "lengthMin": 50, - "minWatched": 50, - "date": "2022-02-18" - }, - { - "episodeID": 50, - "lengthMin": 45, - "minWatched": 45, - "date": "2022-02-28" - }, - { - "episodeID": 60, - "lengthMin": 55, - "minWatched": 55, - "date": "2022-04-02" - } - ] - } - ] - }, - { - "showName": "Dane", - "showId": 16, - "showtype": "tvseries", - "genres" : ["comedy", "drama", "danish"], - "numSeasons" : 2, - "seriesInfo": [ - { - "seasonNum" : 1, - "numEpisodes" : 2, - "episodes": [ - { - "episodeID": 20, - "lengthMin": 65, - "minWatched": 65, - "date": "2022-01-18" - }, - { - "episodeID": 30, - "lengthMin": 60, - "minWatched": 60, - "date": "2022-02-07" - } - ] - }, - { - "seasonNum": 2, - "numEpisodes" : 2, - "episodes": [ - { - "episodeID": 40, - "lengthMin": 50, - "minWatched": 50, - "date": "2022-02-08" - }, - { - "episodeID": 50, - "lengthMin": 45, - "minWatched": 45, - "date": "2022-02-20" - } - ] - } - ] - } - ] - } -) -; +### Begin Script ### +load -file acctstream.ddl +import -table stream_acct -file acctstreamData.json +### End Script ### diff --git a/SampleSchemas/BaggageSchema/baggageData.json b/SampleSchemas/BaggageSchema/baggageData.json new file mode 100644 index 0000000..0ec1241 --- /dev/null +++ b/SampleSchemas/BaggageSchema/baggageData.json @@ -0,0 +1,1439 @@ +{ + "fullName" : "Zina Christenson", + "contactPhone" : "987-210-3029", + "ticketNo" : 1762390789239, + "confNo" : "QB1O0J", + "gender" : "M", + "bagInfo" : [ { + "id" : "79039899145397", + "tagNum" : "17657806228676", + "routing" : "MIA/LAX/MEL", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "MEL", + "flightLegs" : [ { + "flightNo" : "BM604", + "flightDate" : "2019-02-04T00:00:00Z", + "fltRouteSrc" : "MIA", + "fltRouteDest" : "LAX", + "estimatedArrival" : "2019-02-04T05:00:00Z", + "actions" : [ { + "actionAt" : "MIA", + "actionCode" : "ONLOAD to LAX", + "actionTime" : "2019-02-04T00:12:00Z" + }, { + "actionAt" : "MIA", + "actionCode" : "BagTag Scan at MIA", + "actionTime" : "2019-02-03T23:52:00Z" + }, { + "actionAt" : "MIA", + "actionCode" : "Checkin at MIA", + "actionTime" : "2019-02-03T23:55:00Z" + } ] + }, { + "flightNo" : "BM667", + "flightDate" : "2019-02-04T00:12:00Z", + "fltRouteSrc" : "LAX", + "fltRouteDest" : "MEL", + "estimatedArrival" : "2019-02-04T10:14:00Z", + "actions" : [ { + "actionAt" : "MEL", + "actionCode" : "Offload to Carousel at MEL", + "actionTime" : "2019-02-04T10:06:00Z" + }, { + "actionAt" : "LAX", + "actionCode" : "ONLOAD to MEL", + "actionTime" : "2019-02-04T09:41:00Z" + }, { + "actionAt" : "LAX", + "actionCode" : "OFFLOAD from LAX", + "actionTime" : "2019-02-04T09:38:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-02-04T10:08:00Z", + "bagArrivalDate" : "2019-02-04T10:08:00Z" + } ] +} + +{ + "fullName" : "Adelaide Willard", + "contactPhone" : "421-272-8082", + "ticketNo" : 1762392135540, + "confNo" : "DN3I4Q", + "gender" : "M", + "bagInfo" : [ { + "id" : "79039899156435", + "tagNum" : "17657806224224", + "routing" : "GRU/ORD/SEA", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "SEA", + "flightLegs" : [ { + "flightNo" : "BM79", + "flightDate" : "2019-02-15T01:00:00Z", + "fltRouteSrc" : "GRU", + "fltRouteDest" : "ORD", + "estimatedArrival" : "2019-02-15T11:00:00Z", + "actions" : [ { + "actionAt" : "GRU", + "actionCode" : "ONLOAD to ORD", + "actionTime" : "2019-02-15T01:21:00Z" + }, { + "actionAt" : "GRU", + "actionCode" : "BagTag Scan at GRU", + "actionTime" : "2019-02-15T00:55:00Z" + }, { + "actionAt" : "GRU", + "actionCode" : "Checkin at GRU", + "actionTime" : "2019-02-14T23:49:00Z" + } ] + }, { + "flightNo" : "BM907", + "flightDate" : "2019-02-15T01:21:00Z", + "fltRouteSrc" : "ORD", + "fltRouteDest" : "SEA", + "estimatedArrival" : "2019-02-15T21:22:00Z", + "actions" : [ { + "actionAt" : "SEA", + "actionCode" : "Offload to Carousel at SEA", + "actionTime" : "2019-02-15T21:16:00Z" + }, { + "actionAt" : "ORD", + "actionCode" : "ONLOAD to SEA", + "actionTime" : "2019-02-15T20:52:00Z" + }, { + "actionAt" : "ORD", + "actionCode" : "OFFLOAD from ORD", + "actionTime" : "2019-02-15T20:44:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-02-15T21:21:00Z", + "bagArrivalDate" : "2019-02-15T21:21:00Z" + } ] +} + +{ + "fullName" : "Adam Phillips", + "contactPhone" : "893-324-1064", + "ticketNo" : 1762344493810, + "confNo" : "LE6J4Z", + "gender" : "M", + "bagInfo" : [ { + "id" : "79039899165297", + "tagNum" : "17657806255240", + "routing" : "MIA/LAX/MEL", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "MEL", + "flightLegs" : [ { + "flightNo" : "BM604", + "flightDate" : "2019-02-01T06:00:00Z", + "fltRouteSrc" : "MIA", + "fltRouteDest" : "LAX", + "estimatedArrival" : "2019-02-01T11:00:00Z", + "actions" : [ { + "actionAt" : "MIA", + "actionCode" : "ONLOAD to LAX", + "actionTime" : "2019-02-01T06:13:00Z" + }, { + "actionAt" : "MIA", + "actionCode" : "BagTag Scan at MIA", + "actionTime" : "2019-02-01T05:47:00Z" + }, { + "actionAt" : "MIA", + "actionCode" : "Checkin at MIA", + "actionTime" : "2019-02-01T04:38:00Z" + } ] + }, { + "flightNo" : "BM667", + "flightDate" : "2019-02-01T06:13:00Z", + "fltRouteSrc" : "LAX", + "fltRouteDest" : "MEL", + "estimatedArrival" : "2019-02-01T16:15:00Z", + "actions" : [ { + "actionAt" : "MEL", + "actionCode" : "Offload to Carousel at MEL", + "actionTime" : "2019-02-01T16:15:00Z" + }, { + "actionAt" : "LAX", + "actionCode" : "ONLOAD to MEL", + "actionTime" : "2019-02-01T15:35:00Z" + }, { + "actionAt" : "LAX", + "actionCode" : "OFFLOAD from LAX", + "actionTime" : "2019-02-01T15:18:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-02-01T16:13:00Z", + "bagArrivalDate" : "2019-02-01T16:13:00Z" + } ] +} + +{ + "fullName" : "Zulema Martindale", + "contactPhone" : "666-302-0028", + "ticketNo" : 1762340579411, + "confNo" : "CR2C8M", + "gender" : "F", + "bagInfo" : [ { + "id" : "79039899150438", + "tagNum" : "17657806288937", + "routing" : "MIA/LAX/MEL", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "MEL", + "flightLegs" : [ { + "flightNo" : "BM604", + "flightDate" : "2019-02-25T10:00:00Z", + "fltRouteSrc" : "MIA", + "fltRouteDest" : "LAX", + "estimatedArrival" : "2019-02-25T15:00:00Z", + "actions" : [ { + "actionAt" : "MIA", + "actionCode" : "ONLOAD to LAX", + "actionTime" : "2019-02-25T10:23:00Z" + }, { + "actionAt" : "MIA", + "actionCode" : "BagTag Scan at MIA", + "actionTime" : "2019-02-25T09:54:00Z" + }, { + "actionAt" : "MIA", + "actionCode" : "Checkin at MIA", + "actionTime" : "2019-02-25T09:58:00Z" + } ] + }, { + "flightNo" : "BM667", + "flightDate" : "2019-02-25T10:23:00Z", + "fltRouteSrc" : "LAX", + "fltRouteDest" : "MEL", + "estimatedArrival" : "2019-02-25T20:25:00Z", + "actions" : [ { + "actionAt" : "MEL", + "actionCode" : "Offload to Carousel at MEL", + "actionTime" : "2019-02-25T20:16:00Z" + }, { + "actionAt" : "LAX", + "actionCode" : "ONLOAD to MEL", + "actionTime" : "2019-02-25T08:39:00Z" + }, { + "actionAt" : "LAX", + "actionCode" : "OFFLOAD from LAX", + "actionTime" : "2019-02-25T08:22:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-02-25T20:15:00Z", + "bagArrivalDate" : "2019-02-25T20:15:00Z" + } ] +} + +{ + "fullName" : "Dierdre Amador", + "contactPhone" : "165-742-5715", + "ticketNo" : 1762376407826, + "confNo" : "ZG8Z5N", + "gender" : "M", + "bagInfo" : [ { + "id" : "7903989918469", + "tagNum" : "17657806240229", + "routing" : "JFK/MAD", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "MAD", + "flightLegs" : [ { + "flightNo" : "BM495", + "flightDate" : "2019-03-07T07:00:00Z", + "fltRouteSrc" : "JFK", + "fltRouteDest" : "MAD", + "estimatedArrival" : "2019-03-07T14:00:00Z", + "actions" : [ { + "actionAt" : "MAD", + "actionCode" : "Offload to Carousel at MAD", + "actionTime" : "2019-03-07T13:54:00Z" + }, { + "actionAt" : "JFK", + "actionCode" : "ONLOAD to MAD", + "actionTime" : "2019-03-07T07:00:00Z" + }, { + "actionAt" : "JFK", + "actionCode" : "BagTag Scan at JFK", + "actionTime" : "2019-03-07T06:53:00Z" + }, { + "actionAt" : "JFK", + "actionCode" : "Checkin at JFK", + "actionTime" : "2019-03-07T05:03:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-03-07T13:51:00Z", + "bagArrivalDate" : "2019-03-07T13:51:00Z" + } ] +} + +{ + "fullName" : "Henry Jenkins", + "contactPhone" : "960-428-3843", + "ticketNo" : 176234463813, + "confNo" : "MZ2S5R", + "gender" : "F", + "bagInfo" : [ { + "id" : "79039899129693", + "tagNum" : "17657806216554", + "routing" : "SFO/ORD/FRA", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "FRA", + "flightLegs" : [ { + "flightNo" : "BM572", + "flightDate" : "2019-03-02T05:00:00Z", + "fltRouteSrc" : "SFO", + "fltRouteDest" : "ORD", + "estimatedArrival" : "2019-03-02T09:00:00Z", + "actions" : [ { + "actionAt" : "SFO", + "actionCode" : "ONLOAD to ORD", + "actionTime" : "2019-03-02T05:24:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "BagTag Scan at SFO", + "actionTime" : "2019-03-02T04:52:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "Checkin at SFO", + "actionTime" : "2019-03-02T03:28:00Z" + } ] + }, { + "flightNo" : "BM582", + "flightDate" : "2019-03-02T05:24:00Z", + "fltRouteSrc" : "ORD", + "fltRouteDest" : "FRA", + "estimatedArrival" : "2019-03-02T13:24:00Z", + "actions" : [ { + "actionAt" : "FRA", + "actionCode" : "Offload to Carousel at FRA", + "actionTime" : "2019-03-02T13:20:00Z" + }, { + "actionAt" : "ORD", + "actionCode" : "ONLOAD to FRA", + "actionTime" : "2019-03-02T12:54:00Z" + }, { + "actionAt" : "ORD", + "actionCode" : "OFFLOAD from ORD", + "actionTime" : "2019-03-02T12:30:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-03-02T13:18:00Z", + "bagArrivalDate" : "2019-03-02T13:18:00Z" + } ] +} + +{ + "fullName" : "Joanne Diaz", + "contactPhone" : "334-679-5105", + "ticketNo" : 1762383911861, + "confNo" : "CG6O1M", + "gender" : "F", + "bagInfo" : [ { + "id" : "7903989911419", + "tagNum" : "17657806292518", + "routing" : "MIA/LAX/MEL", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "MEL", + "flightLegs" : [ { + "flightNo" : "BM604", + "flightDate" : "2019-02-16T06:00:00Z", + "fltRouteSrc" : "MIA", + "fltRouteDest" : "LAX", + "estimatedArrival" : "2019-02-16T11:00:00Z", + "actions" : [ { + "actionAt" : "MIA", + "actionCode" : "ONLOAD to LAX", + "actionTime" : "2019-02-16T06:24:00Z" + }, { + "actionAt" : "MIA", + "actionCode" : "BagTag Scan at MIA", + "actionTime" : "2019-02-16T05:55:00Z" + }, { + "actionAt" : "MIA", + "actionCode" : "Checkin at MIA", + "actionTime" : "2019-02-16T05:27:00Z" + } ] + }, { + "flightNo" : "BM667", + "flightDate" : "2019-02-16T06:24:00Z", + "fltRouteSrc" : "LAX", + "fltRouteDest" : "MEL", + "estimatedArrival" : "2019-02-16T16:26:00Z", + "actions" : [ { + "actionAt" : "MEL", + "actionCode" : "Offload to Carousel at MEL", + "actionTime" : "2019-02-16T16:22:00Z" + }, { + "actionAt" : "LAX", + "actionCode" : "ONLOAD to MEL", + "actionTime" : "2019-02-16T16:15:00Z" + }, { + "actionAt" : "LAX", + "actionCode" : "OFFLOAD from LAX", + "actionTime" : "2019-02-16T16:00:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-02-16T16:13:00Z", + "bagArrivalDate" : "2019-02-16T16:13:00Z" + } ] +} + +{ + "fullName" : "Kendal Biddle", + "contactPhone" : "619-956-8760", + "ticketNo" : 1762377974281, + "confNo" : "PQ1M8N", + "gender" : "F", + "bagInfo" : [ { + "id" : "79039899189080", + "tagNum" : "17657806296887", + "routing" : "JFK/IST/VIE", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "VIE", + "flightLegs" : [ { + "flightNo" : "BM127", + "flightDate" : "2019-03-04T06:00:00Z", + "fltRouteSrc" : "JFK", + "fltRouteDest" : "IST", + "estimatedArrival" : "2019-03-04T22:00:00Z", + "actions" : [ { + "actionAt" : "JFK", + "actionCode" : "ONLOAD to IST", + "actionTime" : "2019-03-04T06:02:00Z" + }, { + "actionAt" : "JFK", + "actionCode" : "BagTag Scan at JFK", + "actionTime" : "2019-03-04T05:47:00Z" + }, { + "actionAt" : "JFK", + "actionCode" : "Checkin at JFK", + "actionTime" : "2019-03-04T05:16:00Z" + } ] + }, { + "flightNo" : "BM431", + "flightDate" : "2019-03-04T07:02:00Z", + "fltRouteSrc" : "IST", + "fltRouteDest" : "VIE", + "estimatedArrival" : "2019-03-05T12:02:00Z", + "actions" : [ { + "actionAt" : "VIE", + "actionCode" : "Offload to Carousel at VIE", + "actionTime" : "2019-03-04T23:58:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "ONLOAD to VIE", + "actionTime" : "2019-03-05T12:55:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "OFFLOAD from IST", + "actionTime" : "2019-03-05T12:55:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-03-05T12:00:00Z", + "bagArrivalDate" : "2019-03-05T12:00:00Z" + } ] +} + +{ + "fullName" : "Lisbeth Wampler", + "contactPhone" : "796-709-9501", + "ticketNo" : 1762355854464, + "confNo" : "BO5G3H", + "gender" : "M", + "bagInfo" : [ { + "id" : "79039899169442", + "tagNum" : "17657806292229", + "routing" : "LAX/TPE/SGN", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "SGN", + "flightLegs" : [ { + "flightNo" : "BM720", + "flightDate" : "2019-02-09T06:00:00Z", + "fltRouteSrc" : "LAX", + "fltRouteDest" : "TPE", + "estimatedArrival" : "2019-02-10T10:00:00Z", + "actions" : [ { + "actionAt" : "LAX", + "actionCode" : "ONLOAD to TPE", + "actionTime" : "2019-02-09T06:01:00Z" + }, { + "actionAt" : "LAX", + "actionCode" : "BagTag Scan at LAX", + "actionTime" : "2019-02-09T05:46:00Z" + }, { + "actionAt" : "LAX", + "actionCode" : "Checkin at LAX", + "actionTime" : "2019-02-09T04:38:00Z" + } ] + }, { + "flightNo" : "BM668", + "flightDate" : "2019-02-09T20:01:00Z", + "fltRouteSrc" : "TPE", + "fltRouteDest" : "SGN", + "estimatedArrival" : "2019-02-10T10:01:00Z", + "actions" : [ { + "actionAt" : "SGN", + "actionCode" : "Offload to Carousel at SGN", + "actionTime" : "2019-02-10T09:58:00Z" + }, { + "actionAt" : "TPE", + "actionCode" : "ONLOAD to SGN", + "actionTime" : "2019-02-10T23:44:00Z" + }, { + "actionAt" : "TPE", + "actionCode" : "OFFLOAD from TPE", + "actionTime" : "2019-02-10T23:40:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-02-10T10:01:00Z", + "bagArrivalDate" : "2019-02-10T10:01:00Z" + } ] +} + +{ + "fullName" : "Mary Watson", + "contactPhone" : "131-183-0560", + "ticketNo" : 1762340683564, + "confNo" : "KN4D1L", + "gender" : "F", + "bagInfo" : [ { + "id" : "7903989918647", + "tagNum" : "17657806299833", + "routing" : "YYZ/HKG/BLR", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "BLR", + "flightLegs" : [ { + "flightNo" : "BM267", + "flightDate" : "2019-03-13T00:00:00Z", + "fltRouteSrc" : "YYZ", + "fltRouteDest" : "HKG", + "estimatedArrival" : "2019-03-13T15:00:00Z", + "actions" : [ { + "actionAt" : "YYZ", + "actionCode" : "ONLOAD to HKG", + "actionTime" : "2019-03-13T00:21:00Z" + }, { + "actionAt" : "YYZ", + "actionCode" : "BagTag Scan at YYZ", + "actionTime" : "2019-03-12T23:58:00Z" + }, { + "actionAt" : "YYZ", + "actionCode" : "Checkin at YYZ", + "actionTime" : "2019-03-12T23:10:00Z" + } ] + }, { + "flightNo" : "BM115", + "flightDate" : "2019-03-13T00:21:00Z", + "fltRouteSrc" : "HKG", + "fltRouteDest" : "BLR", + "estimatedArrival" : "2019-03-14T06:22:00Z", + "actions" : [ { + "actionAt" : "BLR", + "actionCode" : "Offload to Carousel at BLR", + "actionTime" : "2019-03-14T06:20:00Z" + }, { + "actionAt" : "HKG", + "actionCode" : "ONLOAD to BLR", + "actionTime" : "2019-03-14T05:42:00Z" + }, { + "actionAt" : "HKG", + "actionCode" : "OFFLOAD from HKG", + "actionTime" : "2019-03-14T05:38:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-03-14T06:22:00Z", + "bagArrivalDate" : "2019-03-14T06:22:00Z" + } ] +} + +{ + "fullName" : "Omar Harvey", + "contactPhone" : "978-191-8550", + "ticketNo" : 1762348904343, + "confNo" : "OH2F8U", + "gender" : "F", + "bagInfo" : [ { + "id" : "79039899149056", + "tagNum" : "17657806234185", + "routing" : "MEL/LAX/MIA", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "MIA", + "flightLegs" : [ { + "flightNo" : "BM114", + "flightDate" : "2019-03-01T12:00:00Z", + "fltRouteSrc" : "MEL", + "fltRouteDest" : "LAX", + "estimatedArrival" : "2019-03-02T02:00:00Z", + "actions" : [ { + "actionAt" : "MEL", + "actionCode" : "ONLOAD to LAX", + "actionTime" : "2019-03-01T12:20:00Z" + }, { + "actionAt" : "MEL", + "actionCode" : "BagTag Scan at MEL", + "actionTime" : "2019-03-01T11:52:00Z" + }, { + "actionAt" : "MEL", + "actionCode" : "Checkin at MEL", + "actionTime" : "2019-03-01T11:43:00Z" + } ] + }, { + "flightNo" : "BM866", + "flightDate" : "2019-03-01T12:20:00Z", + "fltRouteSrc" : "LAX", + "fltRouteDest" : "MIA", + "estimatedArrival" : "2019-03-02T16:21:00Z", + "actions" : [ { + "actionAt" : "MIA", + "actionCode" : "Offload to Carousel at MIA", + "actionTime" : "2019-03-02T16:18:00Z" + }, { + "actionAt" : "LAX", + "actionCode" : "ONLOAD to MIA", + "actionTime" : "2019-03-02T16:12:00Z" + }, { + "actionAt" : "LAX", + "actionCode" : "OFFLOAD from LAX", + "actionTime" : "2019-03-02T16:02:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-03-02T16:09:00Z", + "bagArrivalDate" : "2019-03-02T16:09:00Z" + } ] +} + +{ + "fullName" : "Raymond Griffin", + "contactPhone" : "567-710-9972", + "ticketNo" : 1762399766476, + "confNo" : "XT6K7M", + "gender" : "F", + "bagInfo" : [ { + "id" : "79039899179672", + "tagNum" : "17657806243578", + "routing" : "MSQ/FRA/HKG", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "HKG", + "flightLegs" : [ { + "flightNo" : "BM365", + "flightDate" : "2019-02-03T04:00:00Z", + "fltRouteSrc" : "MSQ", + "fltRouteDest" : "FRA", + "estimatedArrival" : "2019-02-03T06:00:00Z", + "actions" : [ { + "actionAt" : "MSQ", + "actionCode" : "ONLOAD to FRA", + "actionTime" : "2019-02-03T04:21:00Z" + }, { + "actionAt" : "MSQ", + "actionCode" : "BagTag Scan at MSQ", + "actionTime" : "2019-02-03T03:49:00Z" + }, { + "actionAt" : "MSQ", + "actionCode" : "Checkin at MSQ", + "actionTime" : "2019-02-03T02:50:00Z" + } ] + }, { + "flightNo" : "BM313", + "flightDate" : "2019-02-03T04:21:00Z", + "fltRouteSrc" : "FRA", + "fltRouteDest" : "HKG", + "estimatedArrival" : "2019-02-03T08:22:00Z", + "actions" : [ { + "actionAt" : "HKG", + "actionCode" : "Offload to Carousel at HKG", + "actionTime" : "2019-02-03T08:15:00Z" + }, { + "actionAt" : "FRA", + "actionCode" : "ONLOAD to HKG", + "actionTime" : "2019-02-03T07:36:00Z" + }, { + "actionAt" : "FRA", + "actionCode" : "OFFLOAD from FRA", + "actionTime" : "2019-02-03T07:23:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-02-03T08:09:00Z", + "bagArrivalDate" : "2019-02-03T08:09:00Z" + } ] +} + +{ + "fullName" : "Doris Martin", + "contactPhone" : "289-564-3497", + "ticketNo" : 1762355527825, + "confNo" : "HJ4J4P", + "gender" : "F", + "bagInfo" : [ { + "id" : "79039899197492", + "tagNum" : "17657806232501", + "routing" : "BZN/SEA/CDG/MXP", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "MXP", + "flightLegs" : [ { + "flightNo" : "BM704", + "flightDate" : "2019-03-22T07:00:00Z", + "fltRouteSrc" : "BZN", + "fltRouteDest" : "SEA", + "estimatedArrival" : "2019-03-22T09:00:00Z", + "actions" : [ { + "actionAt" : "BZN", + "actionCode" : "ONLOAD to SEA", + "actionTime" : "2019-03-22T07:23:00Z" + }, { + "actionAt" : "BZN", + "actionCode" : "BagTag Scan at BZN", + "actionTime" : "2019-03-22T06:58:00Z" + }, { + "actionAt" : "BZN", + "actionCode" : "Checkin at BZN", + "actionTime" : "2019-03-22T05:20:00Z" + } ] + }, { + "flightNo" : "BM578", + "flightDate" : "2019-03-22T07:23:00Z", + "fltRouteSrc" : "SEA", + "fltRouteDest" : "CDG", + "estimatedArrival" : "2019-03-21T23:24:00Z", + "actions" : [ { + "actionAt" : "SEA", + "actionCode" : "ONLOAD to CDG", + "actionTime" : "2019-03-22T11:26:00Z" + }, { + "actionAt" : "SEA", + "actionCode" : "BagTag Scan at SEA", + "actionTime" : "2019-03-22T10:57:00Z" + }, { + "actionAt" : "SEA", + "actionCode" : "OFFLOAD from SEA", + "actionTime" : "2019-03-22T11:07:00Z" + } ] + }, { + "flightNo" : "BM386", + "flightDate" : "2019-03-22T07:23:00Z", + "fltRouteSrc" : "CDG", + "fltRouteDest" : "MXP", + "estimatedArrival" : "2019-03-22T10:24:00Z", + "actions" : [ { + "actionAt" : "MXP", + "actionCode" : "Offload to Carousel at MXP", + "actionTime" : "2019-03-22T10:15:00Z" + }, { + "actionAt" : "CDG", + "actionCode" : "ONLOAD to MXP", + "actionTime" : "2019-03-22T10:09:00Z" + }, { + "actionAt" : "CDG", + "actionCode" : "OFFLOAD from CDG", + "actionTime" : "2019-03-22T10:01:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-03-22T10:17:00Z", + "bagArrivalDate" : "2019-03-22T10:17:00Z" + } ] +} + +{ + "fullName" : "Elane Lemons", + "contactPhone" : "600-918-8404", + "ticketNo" : 1762324912391, + "confNo" : "LN0C8R", + "gender" : "F", + "bagInfo" : [ { + "id" : "79039899168383", + "tagNum" : "1765780623244", + "routing" : "MXP/CDG/SLC/BZN", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "BZN", + "flightLegs" : [ { + "flightNo" : "BM936", + "flightDate" : "2019-03-15T08:00:00Z", + "fltRouteSrc" : "MXP", + "fltRouteDest" : "CDG", + "estimatedArrival" : "2019-03-15T09:00:00Z", + "actions" : [ { + "actionAt" : "MXP", + "actionCode" : "ONLOAD to CDG", + "actionTime" : "2019-03-15T08:13:00Z" + }, { + "actionAt" : "MXP", + "actionCode" : "BagTag Scan at MXP", + "actionTime" : "2019-03-15T07:48:00Z" + }, { + "actionAt" : "MXP", + "actionCode" : "Checkin at MXP", + "actionTime" : "2019-03-15T07:38:00Z" + } ] + }, { + "flightNo" : "BM490", + "flightDate" : "2019-03-15T08:13:00Z", + "fltRouteSrc" : "CDG", + "fltRouteDest" : "SLC", + "estimatedArrival" : "2019-03-15T10:14:00Z", + "actions" : [ { + "actionAt" : "CDG", + "actionCode" : "ONLOAD to SLC", + "actionTime" : "2019-03-15T09:42:00Z" + }, { + "actionAt" : "CDG", + "actionCode" : "BagTag Scan at CDG", + "actionTime" : "2019-03-15T09:17:00Z" + }, { + "actionAt" : "CDG", + "actionCode" : "OFFLOAD from CDG", + "actionTime" : "2019-03-15T09:19:00Z" + } ] + }, { + "flightNo" : "BM170", + "flightDate" : "2019-03-15T08:13:00Z", + "fltRouteSrc" : "SLC", + "fltRouteDest" : "BZN", + "estimatedArrival" : "2019-03-15T10:14:00Z", + "actions" : [ { + "actionAt" : "BZN", + "actionCode" : "Offload to Carousel at BZN", + "actionTime" : "2019-03-15T10:13:00Z" + }, { + "actionAt" : "SLC", + "actionCode" : "ONLOAD to BZN", + "actionTime" : "2019-03-15T10:06:00Z" + }, { + "actionAt" : "SLC", + "actionCode" : "OFFLOAD from SLC", + "actionTime" : "2019-03-15T09:59:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-03-15T10:13:00Z", + "bagArrivalDate" : "2019-03-15T10:13:00Z" + } ] +} + +{ + "fullName" : "Fallon Clements", + "contactPhone" : "849-731-1334", + "ticketNo" : 1762350390409, + "confNo" : "XT1O7T", + "gender" : "M", + "bagInfo" : [ { + "id" : "79039899117466", + "tagNum" : "17657806255507", + "routing" : "MXP/CDG/SLC/BZN", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "BZN", + "flightLegs" : [ { + "flightNo" : "BM936", + "flightDate" : "2019-02-21T12:00:00Z", + "fltRouteSrc" : "MXP", + "fltRouteDest" : "CDG", + "estimatedArrival" : "2019-02-21T13:00:00Z", + "actions" : [ { + "actionAt" : "MXP", + "actionCode" : "ONLOAD to CDG", + "actionTime" : "2019-02-21T12:19:00Z" + }, { + "actionAt" : "MXP", + "actionCode" : "BagTag Scan at MXP", + "actionTime" : "2019-02-20T23:51:00Z" + }, { + "actionAt" : "MXP", + "actionCode" : "Checkin at MXP", + "actionTime" : "2019-02-21T10:51:00Z" + } ] + }, { + "flightNo" : "BM490", + "flightDate" : "2019-02-21T12:19:00Z", + "fltRouteSrc" : "CDG", + "fltRouteDest" : "SLC", + "estimatedArrival" : "2019-02-21T14:19:00Z", + "actions" : [ { + "actionAt" : "CDG", + "actionCode" : "ONLOAD to SLC", + "actionTime" : "2019-02-21T14:05:00Z" + }, { + "actionAt" : "CDG", + "actionCode" : "BagTag Scan at CDG", + "actionTime" : "2019-02-21T13:41:00Z" + }, { + "actionAt" : "CDG", + "actionCode" : "OFFLOAD from CDG", + "actionTime" : "2019-02-21T13:49:00Z" + } ] + }, { + "flightNo" : "BM170", + "flightDate" : "2019-02-21T12:19:00Z", + "fltRouteSrc" : "SLC", + "fltRouteDest" : "BZN", + "estimatedArrival" : "2019-02-21T14:20:00Z", + "actions" : [ { + "actionAt" : "BZN", + "actionCode" : "Offload to Carousel at BZN", + "actionTime" : "2019-02-21T14:15:00Z" + }, { + "actionAt" : "SLC", + "actionCode" : "ONLOAD to BZN", + "actionTime" : "2019-02-21T14:34:00Z" + }, { + "actionAt" : "SLC", + "actionCode" : "OFFLOAD from SLC", + "actionTime" : "2019-02-21T14:11:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-02-21T14:08:00Z", + "bagArrivalDate" : "2019-02-21T14:08:00Z" + } ] +} + +{ + "fullName" : "Gerard Greene", + "contactPhone" : "395-837-3772", + "ticketNo" : 1762341772625, + "confNo" : "MC0E7R", + "gender" : "M", + "bagInfo" : [ { + "id" : "79039899152842", + "tagNum" : "1765780626568", + "routing" : "SFO/IST/ATH/JTR", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "JTR", + "flightLegs" : [ { + "flightNo" : "BM318", + "flightDate" : "2019-03-07T04:00:00Z", + "fltRouteSrc" : "SFO", + "fltRouteDest" : "IST", + "estimatedArrival" : "2019-03-07T17:00:00Z", + "actions" : [ { + "actionAt" : "SFO", + "actionCode" : "ONLOAD to IST", + "actionTime" : "2019-03-07T04:08:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "BagTag Scan at SFO", + "actionTime" : "2019-03-07T03:53:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "Checkin at SFO", + "actionTime" : "2019-03-07T02:20:00Z" + } ] + }, { + "flightNo" : "BM696", + "flightDate" : "2019-03-07T05:08:00Z", + "fltRouteSrc" : "IST", + "fltRouteDest" : "ATH", + "estimatedArrival" : "2019-03-08T04:10:00Z", + "actions" : [ { + "actionAt" : "IST", + "actionCode" : "ONLOAD to ATH", + "actionTime" : "2019-03-08T04:55:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "BagTag Scan at IST", + "actionTime" : "2019-03-08T04:34:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "OFFLOAD from IST", + "actionTime" : "2019-03-08T04:47:00Z" + } ] + }, { + "flightNo" : "BM665", + "flightDate" : "2019-03-07T04:08:00Z", + "fltRouteSrc" : "ATH", + "fltRouteDest" : "JTR", + "estimatedArrival" : "2019-03-07T16:10:00Z", + "actions" : [ { + "actionAt" : "JTR", + "actionCode" : "Offload to Carousel at JTR", + "actionTime" : "2019-03-07T16:09:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "ONLOAD to JTR", + "actionTime" : "2019-03-07T15:51:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "OFFLOAD from ATH", + "actionTime" : "2019-03-07T15:43:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-03-07T16:01:00Z", + "bagArrivalDate" : "2019-03-07T16:01:00Z" + } ] +} + +{ + "fullName" : "Rosalia Triplett", + "contactPhone" : "368-769-5636", + "ticketNo" : 1762311547917, + "confNo" : "FH7G1W", + "gender" : "F", + "bagInfo" : [ { + "id" : "79039899194559", + "tagNum" : "17657806215913", + "routing" : "JFK/IST/VIE", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "VIE", + "flightLegs" : [ { + "flightNo" : "BM127", + "flightDate" : "2019-02-11T01:00:00Z", + "fltRouteSrc" : "JFK", + "fltRouteDest" : "IST", + "estimatedArrival" : "2019-02-11T17:00:00Z", + "actions" : [ { + "actionAt" : "JFK", + "actionCode" : "ONLOAD to IST", + "actionTime" : "2019-02-11T01:12:00Z" + }, { + "actionAt" : "JFK", + "actionCode" : "BagTag Scan at JFK", + "actionTime" : "2019-02-11T00:48:00Z" + }, { + "actionAt" : "JFK", + "actionCode" : "Checkin at JFK", + "actionTime" : "2019-02-10T23:39:00Z" + } ] + }, { + "flightNo" : "BM431", + "flightDate" : "2019-02-11T02:12:00Z", + "fltRouteSrc" : "IST", + "fltRouteDest" : "VIE", + "estimatedArrival" : "2019-02-12T07:12:00Z", + "actions" : [ { + "actionAt" : "VIE", + "actionCode" : "Offload to Carousel at VIE", + "actionTime" : "2019-02-12T07:08:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "ONLOAD to VIE", + "actionTime" : "2019-02-12T07:52:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "OFFLOAD from IST", + "actionTime" : "2019-02-12T07:31:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-02-12T07:04:00Z", + "bagArrivalDate" : "2019-02-12T07:04:00Z" + } ] +} + +{ + "fullName" : "Teena Colley", + "contactPhone" : "539-097-5220", + "ticketNo" : 1762357254392, + "confNo" : "TX1P7E", + "gender" : "M", + "bagInfo" : [ { + "id" : "79039899153973", + "tagNum" : "17657806255823", + "routing" : "MSQ/FRA/HKG", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "HKG", + "flightLegs" : [ { + "flightNo" : "BM365", + "flightDate" : "2019-02-13T07:00:00Z", + "fltRouteSrc" : "MSQ", + "fltRouteDest" : "FRA", + "estimatedArrival" : "2019-02-13T09:00:00Z", + "actions" : [ { + "actionAt" : "MSQ", + "actionCode" : "ONLOAD to FRA", + "actionTime" : "2019-02-13T07:17:00Z" + }, { + "actionAt" : "MSQ", + "actionCode" : "BagTag Scan at MSQ", + "actionTime" : "2019-02-13T06:52:00Z" + }, { + "actionAt" : "MSQ", + "actionCode" : "Checkin at MSQ", + "actionTime" : "2019-02-13T06:11:00Z" + } ] + }, { + "flightNo" : "BM313", + "flightDate" : "2019-02-13T07:17:00Z", + "fltRouteSrc" : "FRA", + "fltRouteDest" : "HKG", + "estimatedArrival" : "2019-02-13T11:18:00Z", + "actions" : [ { + "actionAt" : "HKG", + "actionCode" : "Offload to Carousel at HKG", + "actionTime" : "2019-02-13T11:15:00Z" + }, { + "actionAt" : "FRA", + "actionCode" : "ONLOAD to HKG", + "actionTime" : "2019-02-13T10:39:00Z" + }, { + "actionAt" : "FRA", + "actionCode" : "OFFLOAD from FRA", + "actionTime" : "2019-02-13T10:37:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-02-13T11:15:00Z", + "bagArrivalDate" : "2019-02-13T11:15:00Z" + } ] +} + +{ + "fullName" : "Lucinda Beckman", + "contactPhone" : "364-610-4444", + "ticketNo" : 1762320569757, + "confNo" : "QI3V6Q", + "gender" : "M", + "bagInfo" : [ { + "id" : "79039899187755", + "tagNum" : "17657806240001", + "routing" : "SFO/IST/ATH/JTR", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "JTR", + "flightLegs" : [ { + "flightNo" : "BM318", + "flightDate" : "2019-03-12T03:00:00Z", + "fltRouteSrc" : "SFO", + "fltRouteDest" : "IST", + "estimatedArrival" : "2019-03-12T16:00:00Z", + "actions" : [ { + "actionAt" : "SFO", + "actionCode" : "ONLOAD to IST", + "actionTime" : "2019-03-12T03:11:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "BagTag Scan at SFO", + "actionTime" : "2019-03-12T02:49:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "Checkin at SFO", + "actionTime" : "2019-03-12T01:50:00Z" + } ] + }, { + "flightNo" : "BM696", + "flightDate" : "2019-03-12T04:11:00Z", + "fltRouteSrc" : "IST", + "fltRouteDest" : "ATH", + "estimatedArrival" : "2019-03-13T03:14:00Z", + "actions" : [ { + "actionAt" : "IST", + "actionCode" : "ONLOAD to ATH", + "actionTime" : "2019-03-13T04:10:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "BagTag Scan at IST", + "actionTime" : "2019-03-13T03:56:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "OFFLOAD from IST", + "actionTime" : "2019-03-13T03:59:00Z" + } ] + }, { + "flightNo" : "BM665", + "flightDate" : "2019-03-12T03:11:00Z", + "fltRouteSrc" : "ATH", + "fltRouteDest" : "JTR", + "estimatedArrival" : "2019-03-12T15:12:00Z", + "actions" : [ { + "actionAt" : "JTR", + "actionCode" : "Offload to Carousel at JTR", + "actionTime" : "2019-03-12T15:06:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "ONLOAD to JTR", + "actionTime" : "2019-03-12T14:16:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "OFFLOAD from ATH", + "actionTime" : "2019-03-12T14:13:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-03-12T15:05:00Z", + "bagArrivalDate" : "2019-03-12T15:05:00Z" + } ] +} + +{ + "fullName" : "Michelle Payne", + "contactPhone" : "575-781-6240", + "ticketNo" : 1762330498104, + "confNo" : "RL3J4Q", + "gender" : "F", + "bagInfo" : [ { + "id" : "79039899186259", + "tagNum" : "17657806247861", + "routing" : "SFO/IST/ATH/JTR", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "JTR", + "flightLegs" : [ { + "flightNo" : "BM318", + "flightDate" : "2019-02-02T12:00:00Z", + "fltRouteSrc" : "SFO", + "fltRouteDest" : "IST", + "estimatedArrival" : "2019-02-03T01:00:00Z", + "actions" : [ { + "actionAt" : "SFO", + "actionCode" : "ONLOAD to IST", + "actionTime" : "2019-02-02T12:10:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "BagTag Scan at SFO", + "actionTime" : "2019-02-02T11:47:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "Checkin at SFO", + "actionTime" : "2019-02-02T10:01:00Z" + } ] + }, { + "flightNo" : "BM696", + "flightDate" : "2019-02-02T13:10:00Z", + "fltRouteSrc" : "IST", + "fltRouteDest" : "ATH", + "estimatedArrival" : "2019-02-03T12:12:00Z", + "actions" : [ { + "actionAt" : "IST", + "actionCode" : "ONLOAD to ATH", + "actionTime" : "2019-02-03T13:06:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "BagTag Scan at IST", + "actionTime" : "2019-02-03T12:48:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "OFFLOAD from IST", + "actionTime" : "2019-02-03T13:00:00Z" + } ] + }, { + "flightNo" : "BM665", + "flightDate" : "2019-02-02T12:10:00Z", + "fltRouteSrc" : "ATH", + "fltRouteDest" : "JTR", + "estimatedArrival" : "2019-02-03T00:12:00Z", + "actions" : [ { + "actionAt" : "JTR", + "actionCode" : "Offload to Carousel at JTR", + "actionTime" : "2019-02-03T00:06:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "ONLOAD to JTR", + "actionTime" : "2019-02-03T00:13:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "OFFLOAD from ATH", + "actionTime" : "2019-02-03T00:10:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-02-02T23:59:00Z", + "bagArrivalDate" : "2019-02-02T23:59:00Z" + } ] +} + +{ + "fullName" : "Lorenzo Phil", + "contactPhone" :"364-610-4444", + "ticketNo" : 1762320369957, + "confNo" : "QI3V6Q", + "gender" : "M", + "bagInfo" :[ { + "id" : "79039899187755", + "tagNum" : "17657806240001", + "routing" : "SFO/IST/ATH/JTR", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "JTR", + "flightLegs" : [ { + "flightNo" : "BM318", + "flightDate" : "2019-03-12T03:00:00Z", + "fltRouteSrc" : "SFO", + "fltRouteDest" : "IST", + "estimatedArrival" : "2019-03-12T16:00:00Z", + "actions" : [ { + "actionAt" : "SFO", + "actionCode" : "ONLOAD to IST", + "actionTime" : "2019-03-12T03:11:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "BagTag Scan at SFO", + "actionTime" : "2019-03-12T02:49:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "Checkin at SFO", + "actionTime" : "2019-03-12T01:50:00Z" + } ] + }, { + "flightNo" : "BM696", + "flightDate" : "2019-03-12T04:11:00Z", + "fltRouteSrc" : "IST", + "fltRouteDest" : "ATH", + "estimatedArrival" : "2019-03-13T03:14:00Z", + "actions" : [ { + "actionAt" : "IST", + "actionCode" : "ONLOAD to ATH", + "actionTime" : "2019-03-13T04:10:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "BagTag Scan at IST", + "actionTime" : "2019-03-13T03:56:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "OFFLOAD from IST", + "actionTime" : "2019-03-13T03:59:00Z" + } ] + }, { + "flightNo" : "BM665", + "flightDate" : "2019-03-12T03:11:00Z", + "fltRouteSrc" : "ATH", + "fltRouteDest" : "JTR", + "estimatedArrival" : "2019-03-12T15:12:00Z", + "actions" : [ { + "actionAt" : "JTR", + "actionCode" : "Offload to Carousel at JTR", + "actionTime" : "2019-03-12T15:06:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "ONLOAD to JTR", + "actionTime" : "2019-03-12T14:16:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "OFFLOAD from ATH", + "actionTime" : "2019-03-12T14:13:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-03-12T15:05:00Z", + "bagArrivalDate" : "2019-03-12T15:05:00Z" + }, + { + "id" : "79039899197755", + "tagNum" : "17657806340001", + "routing" : "SFO/IST/ATH/JTR", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "JTR", + "flightLegs" : [ { + "flightNo" : "BM318", + "flightDate" : "2019-03-12T03:00:00Z", + "fltRouteSrc" : "SFO", + "fltRouteDest" : "IST", + "estimatedArrival" : "2019-03-12T16:40:00Z", + "actions" : [ { + "actionAt" : "SFO", + "actionCode" : "ONLOAD to IST", + "actionTime" : "2019-03-12T03:14:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "BagTag Scan at SFO", + "actionTime" : "2019-03-12T02:50:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "Checkin at SFO", + "actionTime" : "2019-03-12T01:58:00Z" + } ] + }, { + "flightNo" : "BM696", + "flightDate" : "2019-03-12T04:11:00Z", + "fltRouteSrc" : "IST", + "fltRouteDest" : "ATH", + "estimatedArrival" : "2019-03-13T03:18:00Z", + "actions" : [ { + "actionAt" : "IST", + "actionCode" : "ONLOAD to ATH", + "actionTime" : "2019-03-13T04:17:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "BagTag Scan at IST", + "actionTime" : "2019-03-13T03:59:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "OFFLOAD from IST", + "actionTime" : "2019-03-13T03:48:00Z" + } ] + }, { + "flightNo" : "BM665", + "flightDate" : "2019-03-12T03:11:00Z", + "fltRouteSrc" : "ATH", + "fltRouteDest" : "JTR", + "estimatedArrival" : "2019-03-12T15:12:00Z", + "actions" : [ { + "actionAt" : "JTR", + "actionCode" : "Offload to Carousel at JTR", + "actionTime" : "2019-03-12T15:06:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "ONLOAD to JTR", + "actionTime" : "2019-03-12T14:16:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "OFFLOAD from ATH", + "actionTime" : "2019-03-12T14:23:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-03-12T16:05:00Z", + "bagArrivalDate" : "2019-03-12T16:25:00Z" + } ] +} + +{ + "fullName" : "Raymond Griffin", + "contactPhone" :"567-710-9972", + "ticketNo" : 1762399766476, + "confNo" : "XT6K7M", + "gender" : "M", + "bagInfo" :[ { + "id" : "79039899179672", + "tagNum" :17657806243578, + "routing" : "MSQ/FRA/HKG", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "HKG", + "flightLegs" : [ { + "flightNo" : "BM365", + "flightDate" : "2019-02-03T04:00:00Z", + "fltRouteSrc" : "MSQ", + "fltRouteDest" : "FRA", + "estimatedArrival" : "2019-02-03T06:00:00Z", + "actions" : [ { + "actionAt" : "MSQ", + "actionCode" : "ONLOAD to FRA", + "actionTime" : "2019-02-03T04:21:00Z" + }, { + "actionAt" : "MSQ", + "actionCode" : "BagTag Scan at MSQ", + "actionTime" : "2019-02-03T03:49:00Z" + }, { + "actionAt" : "MSQ", + "actionCode" : "Checkin at MSQ", + "actionTime" : "2019-02-03T02:50:00Z" + } ] + }, { + "flightNo" : "BM313", + "flightDate" : "2019-02-03T04:21:00Z", + "fltRouteSrc" : "FRA", + "fltRouteDest" : "HKG", + "estimatedArrival" : "2019-02-03T08:22:00Z", + "actions" : [ { + "actionAt" : "HKG", + "actionCode" : "Offload to Carousel at HKG", + "actionTime" : "2019-02-03T08:15:00Z" + }, { + "actionAt" : "FRA", + "actionCode" : "ONLOAD to HKG", + "actionTime" : "2019-02-03T07:36:00Z" + }, { + "actionAt" : "FRA", + "actionCode" : "OFFLOAD from FRA", + "actionTime" : "2019-02-03T07:23:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-02-03T08:09:00Z", + "bagArrivalDate" : "2019-02-03T08:09:00Z" + } ] +} \ No newline at end of file diff --git a/SampleSchemas/BaggageSchema/baggageInfo.ddl b/SampleSchemas/BaggageSchema/baggageInfo.ddl new file mode 100644 index 0000000..d301e4b --- /dev/null +++ b/SampleSchemas/BaggageSchema/baggageInfo.ddl @@ -0,0 +1,9 @@ +CREATE TABLE IF NOT EXISTS BaggageInfo ( +ticketNo LONG, +fullName STRING, +gender STRING, +contactPhone STRING, +confNo STRING, +bagInfo JSON, +PRIMARY KEY (ticketNo) +); \ No newline at end of file diff --git a/SampleSchemas/BaggageSchema/baggageschema_loaddata.sql b/SampleSchemas/BaggageSchema/baggageschema_loaddata.sql index ff0d5f5..5f7c4ec 100644 --- a/SampleSchemas/BaggageSchema/baggageschema_loaddata.sql +++ b/SampleSchemas/BaggageSchema/baggageschema_loaddata.sql @@ -1,1421 +1,4 @@ -### CREATE table if not present ### -CREATE TABLE IF NOT EXISTS BaggageInfo ( -ticketNo LONG, -fullName STRING, -gender STRING, -contactPhone STRING, -confNo STRING, -bagInfo JSON, -PRIMARY KEY (ticketNo) -); - -### row 1 ### -INSERT INTO BaggageInfo VALUES( -1762344493810, -"Adam Phillips", -"M", -"893-324-1064", -"LE6J4Z", -[ { - "id" : "79039899165297", - "tagNum" : "17657806255240", - "routing" : "MIA/LAX/MEL", - "lastActionCode" : "OFFLOAD", - "lastActionDesc" : "OFFLOAD", - "lastSeenStation" : "MEL", - "flightLegs" : [ { - "flightNo" : "BM604", - "flightDate" : "2019-02-01T06:00:00Z", - "fltRouteSrc" : "MIA", - "fltRouteDest" : "LAX", - "estimatedArrival" : "2019-02-01T11:00:00Z", - "actions" : [ { - "actionAt" : "MIA", - "actionCode" : "ONLOAD to LAX", - "actionTime" : "2019-02-01T06:13:00Z" - }, { - "actionAt" : "MIA", - "actionCode" : "BagTag Scan at MIA", - "actionTime" : "2019-02-01T05:47:00Z" - }, { - "actionAt" : "MIA", - "actionCode" : "Checkin at MIA", - "actionTime" : "2019-02-01T04:38:00Z" - } ] - }, { - "flightNo" : "BM667", - "flightDate" : "2019-02-01T06:13:00Z", - "fltRouteSrc" : "LAX", - "fltRouteDest" : "MEL", - "estimatedArrival" : "2019-02-01T16:15:00Z", - "actions" : [ { - "actionAt" : "MEL", - "actionCode" : "Offload to Carousel at MEL", - "actionTime" : "2019-02-01T16:15:00Z" - }, { - "actionAt" : "LAX", - "actionCode" : "ONLOAD to MEL", - "actionTime" : "2019-02-01T15:35:00Z" - }, { - "actionAt" : "LAX", - "actionCode" : "OFFLOAD from LAX", - "actionTime" : "2019-02-01T15:18:00Z" - } ] - } ], - "lastSeenTimeGmt" : "2019-02-01T16:13:00Z", - "bagArrivalDate" : "2019-02-01T16:13:00Z" - } ] -); - -### row 2 ### -INSERT INTO BaggageInfo VALUES( -1762392135540, -"Adelaide Willard", -"M", -"421-272-8082", -"DN3I4Q", -[{ - "id" : "79039899156435", - "tagNum" : "17657806224224", - "routing" : "GRU/ORD/SEA", - "lastActionCode" : "OFFLOAD", - "lastActionDesc" : "OFFLOAD", - "lastSeenStation" : "SEA", - "flightLegs" : [ { - "flightNo" : "BM79", - "flightDate" : "2019-02-15T01:00:00Z", - "fltRouteSrc" : "GRU", - "fltRouteDest" : "ORD", - "estimatedArrival" : "2019-02-15T11:00:00Z", - "actions" : [ { - "actionAt" : "GRU", - "actionCode" : "ONLOAD to ORD", - "actionTime" : "2019-02-15T01:21:00Z" - }, { - "actionAt" : "GRU", - "actionCode" : "BagTag Scan at GRU", - "actionTime" : "2019-02-15T00:55:00Z" - }, { - "actionAt" : "GRU", - "actionCode" : "Checkin at GRU", - "actionTime" : "2019-02-14T23:49:00Z" - } ] - }, { - "flightNo" : "BM907", - "flightDate" : "2019-02-15T01:21:00Z", - "fltRouteSrc" : "ORD", - "fltRouteDest" : "SEA", - "estimatedArrival" : "2019-02-15T21:22:00Z", - "actions" : [ { - "actionAt" : "SEA", - "actionCode" : "Offload to Carousel at SEA", - "actionTime" : "2019-02-15T21:16:00Z" - }, { - "actionAt" : "ORD", - "actionCode" : "ONLOAD to SEA", - "actionTime" : "2019-02-15T20:52:00Z" - }, { - "actionAt" : "ORD", - "actionCode" : "OFFLOAD from ORD", - "actionTime" : "2019-02-15T20:44:00Z" - } ] - } ], - "lastSeenTimeGmt" : "2019-02-15T21:21:00Z", - "bagArrivalDate" : "2019-02-15T21:21:00Z" - } ] -); - -### row 3 ### -INSERT INTO BaggageInfo VALUES( -1762376407826, -"Dierdre Amador", -"M", -"165-742-5715", -"ZG8Z5N", -[ { - "id" : "7903989918469", - "tagNum" : "17657806240229", - "routing" : "JFK/MAD", - "lastActionCode" : "OFFLOAD", - "lastActionDesc" : "OFFLOAD", - "lastSeenStation" : "MAD", - "flightLegs" : [ { - "flightNo" : "BM495", - "flightDate" : "2019-03-07T07:00:00Z", - "fltRouteSrc" : "JFK", - "fltRouteDest" : "MAD", - "estimatedArrival" : "2019-03-07T14:00:00Z", - "actions" : [ { - "actionAt" : "MAD", - "actionCode" : "Offload to Carousel at MAD", - "actionTime" : "2019-03-07T13:54:00Z" - }, { - "actionAt" : "JFK", - "actionCode" : "ONLOAD to MAD", - "actionTime" : "2019-03-07T07:00:00Z" - }, { - "actionAt" : "JFK", - "actionCode" : "BagTag Scan at JFK", - "actionTime" : "2019-03-07T06:53:00Z" - }, { - "actionAt" : "JFK", - "actionCode" : "Checkin at JFK", - "actionTime" : "2019-03-07T05:03:00Z" - } ] - } ], - "lastSeenTimeGmt" : "2019-03-07T13:51:00Z", - "bagArrivalDate" : "2019-03-07T13:51:00Z" - } ] -); - -### row 4 ### -INSERT INTO BaggageInfo VALUES( -1762355527825, -"Doris Martin", -"F", -"289-564-3497", -"HJ4J4P", -[{ - "id" : "79039899197492", - "tagNum" : "17657806232501", - "routing" : "BZN/SEA/CDG/MXP", - "lastActionCode" : "OFFLOAD", - "lastActionDesc" : "OFFLOAD", - "lastSeenStation" : "MXP", - "flightLegs" : [ { - "flightNo" : "BM704", - "flightDate" : "2019-03-22T07:00:00Z", - "fltRouteSrc" : "BZN", - "fltRouteDest" : "SEA", - "estimatedArrival" : "2019-03-22T09:00:00Z", - "actions" : [ { - "actionAt" : "BZN", - "actionCode" : "ONLOAD to SEA", - "actionTime" : "2019-03-22T07:23:00Z" - }, { - "actionAt" : "BZN", - "actionCode" : "BagTag Scan at BZN", - "actionTime" : "2019-03-22T06:58:00Z" - }, { - "actionAt" : "BZN", - "actionCode" : "Checkin at BZN", - "actionTime" : "2019-03-22T05:20:00Z" - } ] - }, { - "flightNo" : "BM578", - "flightDate" : "2019-03-22T07:23:00Z", - "fltRouteSrc" : "SEA", - "fltRouteDest" : "CDG", - "estimatedArrival" : "2019-03-21T23:24:00Z", - "actions" : [ { - "actionAt" : "SEA", - "actionCode" : "ONLOAD to CDG", - "actionTime" : "2019-03-22T11:26:00Z" - }, { - "actionAt" : "SEA", - "actionCode" : "BagTag Scan at SEA", - "actionTime" : "2019-03-22T10:57:00Z" - }, { - "actionAt" : "SEA", - "actionCode" : "OFFLOAD from SEA", - "actionTime" : "2019-03-22T11:07:00Z" - } ] - }, { - "flightNo" : "BM386", - "flightDate" : "2019-03-22T07:23:00Z", - "fltRouteSrc" : "CDG", - "fltRouteDest" : "MXP", - "estimatedArrival" : "2019-03-22T10:24:00Z", - "actions" : [ { - "actionAt" : "MXP", - "actionCode" : "Offload to Carousel at MXP", - "actionTime" : "2019-03-22T10:15:00Z" - }, { - "actionAt" : "CDG", - "actionCode" : "ONLOAD to MXP", - "actionTime" : "2019-03-22T10:09:00Z" - }, { - "actionAt" : "CDG", - "actionCode" : "OFFLOAD from CDG", - "actionTime" : "2019-03-22T10:01:00Z" - } ] - } ], - "lastSeenTimeGmt" : "2019-03-22T10:17:00Z", - "bagArrivalDate" : "2019-03-22T10:17:00Z" -}] -); - -### row 5 ### -INSERT INTO BaggageInfo VALUES( -1762324912391, -"Elane Lemons", -"F", -"600-918-8404", -"LN0C8R", -[ { - "id" : "79039899168383", - "tagNum" : "1765780623244", - "routing" : "MXP/CDG/SLC/BZN", - "lastActionCode" : "OFFLOAD", - "lastActionDesc" : "OFFLOAD", - "lastSeenStation" : "BZN", - "flightLegs" : [ { - "flightNo" : "BM936", - "flightDate" : "2019-03-15T08:00:00Z", - "fltRouteSrc" : "MXP", - "fltRouteDest" : "CDG", - "estimatedArrival" : "2019-03-15T09:00:00Z", - "actions" : [ { - "actionAt" : "MXP", - "actionCode" : "ONLOAD to CDG", - "actionTime" : "2019-03-15T08:13:00Z" - }, { - "actionAt" : "MXP", - "actionCode" : "BagTag Scan at MXP", - "actionTime" : "2019-03-15T07:48:00Z" - }, { - "actionAt" : "MXP", - "actionCode" : "Checkin at MXP", - "actionTime" : "2019-03-15T07:38:00Z" - } ] - }, { - "flightNo" : "BM490", - "flightDate" : "2019-03-15T08:13:00Z", - "fltRouteSrc" : "CDG", - "fltRouteDest" : "SLC", - "estimatedArrival" : "2019-03-15T10:14:00Z", - "actions" : [ { - "actionAt" : "CDG", - "actionCode" : "ONLOAD to SLC", - "actionTime" : "2019-03-15T09:42:00Z" - }, { - "actionAt" : "CDG", - "actionCode" : "BagTag Scan at CDG", - "actionTime" : "2019-03-15T09:17:00Z" - }, { - "actionAt" : "CDG", - "actionCode" : "OFFLOAD from CDG", - "actionTime" : "2019-03-15T09:19:00Z" - } ] - }, { - "flightNo" : "BM170", - "flightDate" : "2019-03-15T08:13:00Z", - "fltRouteSrc" : "SLC", - "fltRouteDest" : "BZN", - "estimatedArrival" : "2019-03-15T10:14:00Z", - "actions" : [ { - "actionAt" : "BZN", - "actionCode" : "Offload to Carousel at BZN", - "actionTime" : "2019-03-15T10:13:00Z" - }, { - "actionAt" : "SLC", - "actionCode" : "ONLOAD to BZN", - "actionTime" : "2019-03-15T10:06:00Z" - }, { - "actionAt" : "SLC", - "actionCode" : "OFFLOAD from SLC", - "actionTime" : "2019-03-15T09:59:00Z" - } ] - } ], - "lastSeenTimeGmt" : "2019-03-15T10:13:00Z", - "bagArrivalDate" : "2019-03-15T10:13:00Z" - } ] -); - - -### row 6 ### -INSERT INTO BaggageInfo VALUES( -1762350390409, -"Fallon Clements", -"M", -"849-731-1334", -"XT1O7T", -[ { - "id" : "79039899117466", - "tagNum" : "17657806255507", - "routing" : "MXP/CDG/SLC/BZN", - "lastActionCode" : "OFFLOAD", - "lastActionDesc" : "OFFLOAD", - "lastSeenStation" : "BZN", - "flightLegs" : [ { - "flightNo" : "BM936", - "flightDate" : "2019-02-21T12:00:00Z", - "fltRouteSrc" : "MXP", - "fltRouteDest" : "CDG", - "estimatedArrival" : "2019-02-21T13:00:00Z", - "actions" : [ { - "actionAt" : "MXP", - "actionCode" : "ONLOAD to CDG", - "actionTime" : "2019-02-21T12:19:00Z" - }, { - "actionAt" : "MXP", - "actionCode" : "BagTag Scan at MXP", - "actionTime" : "2019-02-20T23:51:00Z" - }, { - "actionAt" : "MXP", - "actionCode" : "Checkin at MXP", - "actionTime" : "2019-02-21T10:51:00Z" - } ] - }, { - "flightNo" : "BM490", - "flightDate" : "2019-02-21T12:19:00Z", - "fltRouteSrc" : "CDG", - "fltRouteDest" : "SLC", - "estimatedArrival" : "2019-02-21T14:19:00Z", - "actions" : [ { - "actionAt" : "CDG", - "actionCode" : "ONLOAD to SLC", - "actionTime" : "2019-02-21T14:05:00Z" - }, { - "actionAt" : "CDG", - "actionCode" : "BagTag Scan at CDG", - "actionTime" : "2019-02-21T13:41:00Z" - }, { - "actionAt" : "CDG", - "actionCode" : "OFFLOAD from CDG", - "actionTime" : "2019-02-21T13:49:00Z" - } ] - }, { - "flightNo" : "BM170", - "flightDate" : "2019-02-21T12:19:00Z", - "fltRouteSrc" : "SLC", - "fltRouteDest" : "BZN", - "estimatedArrival" : "2019-02-21T14:20:00Z", - "actions" : [ { - "actionAt" : "BZN", - "actionCode" : "Offload to Carousel at BZN", - "actionTime" : "2019-02-21T14:15:00Z" - }, { - "actionAt" : "SLC", - "actionCode" : "ONLOAD to BZN", - "actionTime" : "2019-02-21T14:34:00Z" - }, { - "actionAt" : "SLC", - "actionCode" : "OFFLOAD from SLC", - "actionTime" : "2019-02-21T14:11:00Z" - } ] - } ], - "lastSeenTimeGmt" : "2019-02-21T14:08:00Z", - "bagArrivalDate" : "2019-02-21T14:08:00Z" - } ] -); - -### row 7 ### -INSERT INTO BaggageInfo VALUES( -1762341772625, -"Gerard Greene", -"M", -"395-837-3772", -"MC0E7R", -[ { - "id" : "79039899152842", - "tagNum" : "1765780626568", - "routing" : "SFO/IST/ATH/JTR", - "lastActionCode" : "OFFLOAD", - "lastActionDesc" : "OFFLOAD", - "lastSeenStation" : "JTR", - "flightLegs" : [ { - "flightNo" : "BM318", - "flightDate" : "2019-03-07T04:00:00Z", - "fltRouteSrc" : "SFO", - "fltRouteDest" : "IST", - "estimatedArrival" : "2019-03-07T17:00:00Z", - "actions" : [ { - "actionAt" : "SFO", - "actionCode" : "ONLOAD to IST", - "actionTime" : "2019-03-07T04:08:00Z" - }, { - "actionAt" : "SFO", - "actionCode" : "BagTag Scan at SFO", - "actionTime" : "2019-03-07T03:53:00Z" - }, { - "actionAt" : "SFO", - "actionCode" : "Checkin at SFO", - "actionTime" : "2019-03-07T02:20:00Z" - } ] - }, { - "flightNo" : "BM696", - "flightDate" : "2019-03-07T05:08:00Z", - "fltRouteSrc" : "IST", - "fltRouteDest" : "ATH", - "estimatedArrival" : "2019-03-08T04:10:00Z", - "actions" : [ { - "actionAt" : "IST", - "actionCode" : "ONLOAD to ATH", - "actionTime" : "2019-03-08T04:55:00Z" - }, { - "actionAt" : "IST", - "actionCode" : "BagTag Scan at IST", - "actionTime" : "2019-03-08T04:34:00Z" - }, { - "actionAt" : "IST", - "actionCode" : "OFFLOAD from IST", - "actionTime" : "2019-03-08T04:47:00Z" - } ] - }, { - "flightNo" : "BM665", - "flightDate" : "2019-03-07T04:08:00Z", - "fltRouteSrc" : "ATH", - "fltRouteDest" : "JTR", - "estimatedArrival" : "2019-03-07T16:10:00Z", - "actions" : [ { - "actionAt" : "JTR", - "actionCode" : "Offload to Carousel at JTR", - "actionTime" : "2019-03-07T16:09:00Z" - }, { - "actionAt" : "ATH", - "actionCode" : "ONLOAD to JTR", - "actionTime" : "2019-03-07T15:51:00Z" - }, { - "actionAt" : "ATH", - "actionCode" : "OFFLOAD from ATH", - "actionTime" : "2019-03-07T15:43:00Z" - } ] - } ], - "lastSeenTimeGmt" : "2019-03-07T16:01:00Z", - "bagArrivalDate" : "2019-03-07T16:01:00Z" - } ] -); - - -### row 8 ### -INSERT INTO BaggageInfo VALUES( -176234463813, -"Henry Jenkins", -"F", -"960-428-3843", -"MZ2S5R", -[ { - "id" : "79039899129693", - "tagNum" : "17657806216554", - "routing" : "SFO/ORD/FRA", - "lastActionCode" : "OFFLOAD", - "lastActionDesc" : "OFFLOAD", - "lastSeenStation" : "FRA", - "flightLegs" : [ { - "flightNo" : "BM572", - "flightDate" : "2019-03-02T05:00:00Z", - "fltRouteSrc" : "SFO", - "fltRouteDest" : "ORD", - "estimatedArrival" : "2019-03-02T09:00:00Z", - "actions" : [ { - "actionAt" : "SFO", - "actionCode" : "ONLOAD to ORD", - "actionTime" : "2019-03-02T05:24:00Z" - }, { - "actionAt" : "SFO", - "actionCode" : "BagTag Scan at SFO", - "actionTime" : "2019-03-02T04:52:00Z" - }, { - "actionAt" : "SFO", - "actionCode" : "Checkin at SFO", - "actionTime" : "2019-03-02T03:28:00Z" - } ] - }, { - "flightNo" : "BM582", - "flightDate" : "2019-03-02T05:24:00Z", - "fltRouteSrc" : "ORD", - "fltRouteDest" : "FRA", - "estimatedArrival" : "2019-03-02T13:24:00Z", - "actions" : [ { - "actionAt" : "FRA", - "actionCode" : "Offload to Carousel at FRA", - "actionTime" : "2019-03-02T13:20:00Z" - }, { - "actionAt" : "ORD", - "actionCode" : "ONLOAD to FRA", - "actionTime" : "2019-03-02T12:54:00Z" - }, { - "actionAt" : "ORD", - "actionCode" : "OFFLOAD from ORD", - "actionTime" : "2019-03-02T12:30:00Z" - } ] - } ], - "lastSeenTimeGmt" : "2019-03-02T13:18:00Z", - "bagArrivalDate" : "2019-03-02T13:18:00Z" - } ] -); - -### row 9 ### -INSERT INTO BaggageInfo VALUES( -1762383911861, -"Joanne Diaz", -"F", -"334-679-5105", -"CG6O1M", -[ { - "id" : "7903989911419", - "tagNum" : "17657806292518", - "routing" : "MIA/LAX/MEL", - "lastActionCode" : "OFFLOAD", - "lastActionDesc" : "OFFLOAD", - "lastSeenStation" : "MEL", - "flightLegs" : [ { - "flightNo" : "BM604", - "flightDate" : "2019-02-16T06:00:00Z", - "fltRouteSrc" : "MIA", - "fltRouteDest" : "LAX", - "estimatedArrival" : "2019-02-16T11:00:00Z", - "actions" : [ { - "actionAt" : "MIA", - "actionCode" : "ONLOAD to LAX", - "actionTime" : "2019-02-16T06:24:00Z" - }, { - "actionAt" : "MIA", - "actionCode" : "BagTag Scan at MIA", - "actionTime" : "2019-02-16T05:55:00Z" - }, { - "actionAt" : "MIA", - "actionCode" : "Checkin at MIA", - "actionTime" : "2019-02-16T05:27:00Z" - } ] - }, { - "flightNo" : "BM667", - "flightDate" : "2019-02-16T06:24:00Z", - "fltRouteSrc" : "LAX", - "fltRouteDest" : "MEL", - "estimatedArrival" : "2019-02-16T16:26:00Z", - "actions" : [ { - "actionAt" : "MEL", - "actionCode" : "Offload to Carousel at MEL", - "actionTime" : "2019-02-16T16:22:00Z" - }, { - "actionAt" : "LAX", - "actionCode" : "ONLOAD to MEL", - "actionTime" : "2019-02-16T16:15:00Z" - }, { - "actionAt" : "LAX", - "actionCode" : "OFFLOAD from LAX", - "actionTime" : "2019-02-16T16:00:00Z" - } ] - } ], - "lastSeenTimeGmt" : "2019-02-16T16:13:00Z", - "bagArrivalDate" : "2019-02-16T16:13:00Z" - } ] -); - - -### row 10 ### -INSERT INTO BaggageInfo VALUES( -1762377974281, -"Kendal Biddle", -"F", -"619-956-8760", -"PQ1M8N", -[ { - "id" : "79039899189080", - "tagNum" : "17657806296887", - "routing" : "JFK/IST/VIE", - "lastActionCode" : "OFFLOAD", - "lastActionDesc" : "OFFLOAD", - "lastSeenStation" : "VIE", - "flightLegs" : [ { - "flightNo" : "BM127", - "flightDate" : "2019-03-04T06:00:00Z", - "fltRouteSrc" : "JFK", - "fltRouteDest" : "IST", - "estimatedArrival" : "2019-03-04T22:00:00Z", - "actions" : [ { - "actionAt" : "JFK", - "actionCode" : "ONLOAD to IST", - "actionTime" : "2019-03-04T06:02:00Z" - }, { - "actionAt" : "JFK", - "actionCode" : "BagTag Scan at JFK", - "actionTime" : "2019-03-04T05:47:00Z" - }, { - "actionAt" : "JFK", - "actionCode" : "Checkin at JFK", - "actionTime" : "2019-03-04T05:16:00Z" - } ] - }, { - "flightNo" : "BM431", - "flightDate" : "2019-03-04T07:02:00Z", - "fltRouteSrc" : "IST", - "fltRouteDest" : "VIE", - "estimatedArrival" : "2019-03-05T12:02:00Z", - "actions" : [ { - "actionAt" : "VIE", - "actionCode" : "Offload to Carousel at VIE", - "actionTime" : "2019-03-04T23:58:00Z" - }, { - "actionAt" : "IST", - "actionCode" : "ONLOAD to VIE", - "actionTime" : "2019-03-05T12:55:00Z" - }, { - "actionAt" : "IST", - "actionCode" : "OFFLOAD from IST", - "actionTime" : "2019-03-05T12:55:00Z" - } ] - } ], - "lastSeenTimeGmt" : "2019-03-05T12:00:00Z", - "bagArrivalDate" : "2019-03-05T12:00:00Z" - } ] -); - -### row 11 ### -INSERT INTO BaggageInfo VALUES( -1762355854464, -"Lisbeth Wampler", -"M", -"796-709-9501", -"BO5G3H", -[ { - "id" : "79039899169442", - "tagNum" : "17657806292229", - "routing" : "LAX/TPE/SGN", - "lastActionCode" : "OFFLOAD", - "lastActionDesc" : "OFFLOAD", - "lastSeenStation" : "SGN", - "flightLegs" : [ { - "flightNo" : "BM720", - "flightDate" : "2019-02-09T06:00:00Z", - "fltRouteSrc" : "LAX", - "fltRouteDest" : "TPE", - "estimatedArrival" : "2019-02-10T10:00:00Z", - "actions" : [ { - "actionAt" : "LAX", - "actionCode" : "ONLOAD to TPE", - "actionTime" : "2019-02-09T06:01:00Z" - }, { - "actionAt" : "LAX", - "actionCode" : "BagTag Scan at LAX", - "actionTime" : "2019-02-09T05:46:00Z" - }, { - "actionAt" : "LAX", - "actionCode" : "Checkin at LAX", - "actionTime" : "2019-02-09T04:38:00Z" - } ] - }, { - "flightNo" : "BM668", - "flightDate" : "2019-02-09T20:01:00Z", - "fltRouteSrc" : "TPE", - "fltRouteDest" : "SGN", - "estimatedArrival" : "2019-02-10T10:01:00Z", - "actions" : [ { - "actionAt" : "SGN", - "actionCode" : "Offload to Carousel at SGN", - "actionTime" : "2019-02-10T09:58:00Z" - }, { - "actionAt" : "TPE", - "actionCode" : "ONLOAD to SGN", - "actionTime" : "2019-02-10T23:44:00Z" - }, { - "actionAt" : "TPE", - "actionCode" : "OFFLOAD from TPE", - "actionTime" : "2019-02-10T23:40:00Z" - } ] - } ], - "lastSeenTimeGmt" : "2019-02-10T10:01:00Z", - "bagArrivalDate" : "2019-02-10T10:01:00Z" - } ] -); - -### row 12 ### -INSERT INTO BaggageInfo VALUES( -1762320569757, -"Lucinda Beckman", -"M", -"364-610-4444", -"QI3V6Q", -[ { - "id" : "79039899187755", - "tagNum" : "17657806240001", - "routing" : "SFO/IST/ATH/JTR", - "lastActionCode" : "OFFLOAD", - "lastActionDesc" : "OFFLOAD", - "lastSeenStation" : "JTR", - "flightLegs" : [ { - "flightNo" : "BM318", - "flightDate" : "2019-03-12T03:00:00Z", - "fltRouteSrc" : "SFO", - "fltRouteDest" : "IST", - "estimatedArrival" : "2019-03-12T16:00:00Z", - "actions" : [ { - "actionAt" : "SFO", - "actionCode" : "ONLOAD to IST", - "actionTime" : "2019-03-12T03:11:00Z" - }, { - "actionAt" : "SFO", - "actionCode" : "BagTag Scan at SFO", - "actionTime" : "2019-03-12T02:49:00Z" - }, { - "actionAt" : "SFO", - "actionCode" : "Checkin at SFO", - "actionTime" : "2019-03-12T01:50:00Z" - } ] - }, { - "flightNo" : "BM696", - "flightDate" : "2019-03-12T04:11:00Z", - "fltRouteSrc" : "IST", - "fltRouteDest" : "ATH", - "estimatedArrival" : "2019-03-13T03:14:00Z", - "actions" : [ { - "actionAt" : "IST", - "actionCode" : "ONLOAD to ATH", - "actionTime" : "2019-03-13T04:10:00Z" - }, { - "actionAt" : "IST", - "actionCode" : "BagTag Scan at IST", - "actionTime" : "2019-03-13T03:56:00Z" - }, { - "actionAt" : "IST", - "actionCode" : "OFFLOAD from IST", - "actionTime" : "2019-03-13T03:59:00Z" - } ] - }, { - "flightNo" : "BM665", - "flightDate" : "2019-03-12T03:11:00Z", - "fltRouteSrc" : "ATH", - "fltRouteDest" : "JTR", - "estimatedArrival" : "2019-03-12T15:12:00Z", - "actions" : [ { - "actionAt" : "JTR", - "actionCode" : "Offload to Carousel at JTR", - "actionTime" : "2019-03-12T15:06:00Z" - }, { - "actionAt" : "ATH", - "actionCode" : "ONLOAD to JTR", - "actionTime" : "2019-03-12T14:16:00Z" - }, { - "actionAt" : "ATH", - "actionCode" : "OFFLOAD from ATH", - "actionTime" : "2019-03-12T14:13:00Z" - } ] - } ], - "lastSeenTimeGmt" : "2019-03-12T15:05:00Z", - "bagArrivalDate" : "2019-03-12T15:05:00Z" - } ] -); - - -### row 13 ### -INSERT INTO BaggageInfo VALUES( -1762340683564, -"Mary Watson", -"F", -"131-183-0560", -"KN4D1L", -[ { - "id" : "7903989918647", - "tagNum" : "17657806299833", - "routing" : "YYZ/HKG/BLR", - "lastActionCode" : "OFFLOAD", - "lastActionDesc" : "OFFLOAD", - "lastSeenStation" : "BLR", - "flightLegs" : [ { - "flightNo" : "BM267", - "flightDate" : "2019-03-13T00:00:00Z", - "fltRouteSrc" : "YYZ", - "fltRouteDest" : "HKG", - "estimatedArrival" : "2019-03-13T15:00:00Z", - "actions" : [ { - "actionAt" : "YYZ", - "actionCode" : "ONLOAD to HKG", - "actionTime" : "2019-03-13T00:21:00Z" - }, { - "actionAt" : "YYZ", - "actionCode" : "BagTag Scan at YYZ", - "actionTime" : "2019-03-12T23:58:00Z" - }, { - "actionAt" : "YYZ", - "actionCode" : "Checkin at YYZ", - "actionTime" : "2019-03-12T23:10:00Z" - } ] - }, { - "flightNo" : "BM115", - "flightDate" : "2019-03-13T00:21:00Z", - "fltRouteSrc" : "HKG", - "fltRouteDest" : "BLR", - "estimatedArrival" : "2019-03-14T06:22:00Z", - "actions" : [ { - "actionAt" : "BLR", - "actionCode" : "Offload to Carousel at BLR", - "actionTime" : "2019-03-14T06:20:00Z" - }, { - "actionAt" : "HKG", - "actionCode" : "ONLOAD to BLR", - "actionTime" : "2019-03-14T05:42:00Z" - }, { - "actionAt" : "HKG", - "actionCode" : "OFFLOAD from HKG", - "actionTime" : "2019-03-14T05:38:00Z" - } ] - } ], - "lastSeenTimeGmt" : "2019-03-14T06:22:00Z", - "bagArrivalDate" : "2019-03-14T06:22:00Z" - } ] -); - -### row 14 ### -INSERT INTO BaggageInfo VALUES( -1762330498104, -"Michelle Payne", -"F", -"575-781-6240", -"RL3J4Q", -[ { - "id" : "79039899186259", - "tagNum" : "17657806247861", - "routing" : "SFO/IST/ATH/JTR", - "lastActionCode" : "OFFLOAD", - "lastActionDesc" : "OFFLOAD", - "lastSeenStation" : "JTR", - "flightLegs" : [ { - "flightNo" : "BM318", - "flightDate" : "2019-02-02T12:00:00Z", - "fltRouteSrc" : "SFO", - "fltRouteDest" : "IST", - "estimatedArrival" : "2019-02-03T01:00:00Z", - "actions" : [ { - "actionAt" : "SFO", - "actionCode" : "ONLOAD to IST", - "actionTime" : "2019-02-02T12:10:00Z" - }, { - "actionAt" : "SFO", - "actionCode" : "BagTag Scan at SFO", - "actionTime" : "2019-02-02T11:47:00Z" - }, { - "actionAt" : "SFO", - "actionCode" : "Checkin at SFO", - "actionTime" : "2019-02-02T10:01:00Z" - } ] - }, { - "flightNo" : "BM696", - "flightDate" : "2019-02-02T13:10:00Z", - "fltRouteSrc" : "IST", - "fltRouteDest" : "ATH", - "estimatedArrival" : "2019-02-03T12:12:00Z", - "actions" : [ { - "actionAt" : "IST", - "actionCode" : "ONLOAD to ATH", - "actionTime" : "2019-02-03T13:06:00Z" - }, { - "actionAt" : "IST", - "actionCode" : "BagTag Scan at IST", - "actionTime" : "2019-02-03T12:48:00Z" - }, { - "actionAt" : "IST", - "actionCode" : "OFFLOAD from IST", - "actionTime" : "2019-02-03T13:00:00Z" - } ] - }, { - "flightNo" : "BM665", - "flightDate" : "2019-02-02T12:10:00Z", - "fltRouteSrc" : "ATH", - "fltRouteDest" : "JTR", - "estimatedArrival" : "2019-02-03T00:12:00Z", - "actions" : [ { - "actionAt" : "JTR", - "actionCode" : "Offload to Carousel at JTR", - "actionTime" : "2019-02-03T00:06:00Z" - }, { - "actionAt" : "ATH", - "actionCode" : "ONLOAD to JTR", - "actionTime" : "2019-02-03T00:13:00Z" - }, { - "actionAt" : "ATH", - "actionCode" : "OFFLOAD from ATH", - "actionTime" : "2019-02-03T00:10:00Z" - } ] - } ], - "lastSeenTimeGmt" : "2019-02-02T23:59:00Z", - "bagArrivalDate" : "2019-02-02T23:59:00Z" - } ] -); - - -### row 15 ### -INSERT INTO BaggageInfo VALUES( -1762348904343, -"Omar Harvey", -"F", -"978-191-8550", -"OH2F8U", -[ { - "id" : "79039899149056", - "tagNum" : "17657806234185", - "routing" : "MEL/LAX/MIA", - "lastActionCode" : "OFFLOAD", - "lastActionDesc" : "OFFLOAD", - "lastSeenStation" : "MIA", - "flightLegs" : [ { - "flightNo" : "BM114", - "flightDate" : "2019-03-01T12:00:00Z", - "fltRouteSrc" : "MEL", - "fltRouteDest" : "LAX", - "estimatedArrival" : "2019-03-02T02:00:00Z", - "actions" : [ { - "actionAt" : "MEL", - "actionCode" : "ONLOAD to LAX", - "actionTime" : "2019-03-01T12:20:00Z" - }, { - "actionAt" : "MEL", - "actionCode" : "BagTag Scan at MEL", - "actionTime" : "2019-03-01T11:52:00Z" - }, { - "actionAt" : "MEL", - "actionCode" : "Checkin at MEL", - "actionTime" : "2019-03-01T11:43:00Z" - } ] - }, { - "flightNo" : "BM866", - "flightDate" : "2019-03-01T12:20:00Z", - "fltRouteSrc" : "LAX", - "fltRouteDest" : "MIA", - "estimatedArrival" : "2019-03-02T16:21:00Z", - "actions" : [ { - "actionAt" : "MIA", - "actionCode" : "Offload to Carousel at MIA", - "actionTime" : "2019-03-02T16:18:00Z" - }, { - "actionAt" : "LAX", - "actionCode" : "ONLOAD to MIA", - "actionTime" : "2019-03-02T16:12:00Z" - }, { - "actionAt" : "LAX", - "actionCode" : "OFFLOAD from LAX", - "actionTime" : "2019-03-02T16:02:00Z" - } ] - } ], - "lastSeenTimeGmt" : "2019-03-02T16:09:00Z", - "bagArrivalDate" : "2019-03-02T16:09:00Z" - } ] -); - -### row 16 ### -INSERT INTO BaggageInfo VALUES( -1762399766476, -"Raymond Griffin", -"F", -"567-710-9972", -"XT6K7M", -[ { - "id" : "79039899179672", - "tagNum" : "17657806243578", - "routing" : "MSQ/FRA/HKG", - "lastActionCode" : "OFFLOAD", - "lastActionDesc" : "OFFLOAD", - "lastSeenStation" : "HKG", - "flightLegs" : [ { - "flightNo" : "BM365", - "flightDate" : "2019-02-03T04:00:00Z", - "fltRouteSrc" : "MSQ", - "fltRouteDest" : "FRA", - "estimatedArrival" : "2019-02-03T06:00:00Z", - "actions" : [ { - "actionAt" : "MSQ", - "actionCode" : "ONLOAD to FRA", - "actionTime" : "2019-02-03T04:21:00Z" - }, { - "actionAt" : "MSQ", - "actionCode" : "BagTag Scan at MSQ", - "actionTime" : "2019-02-03T03:49:00Z" - }, { - "actionAt" : "MSQ", - "actionCode" : "Checkin at MSQ", - "actionTime" : "2019-02-03T02:50:00Z" - } ] - }, { - "flightNo" : "BM313", - "flightDate" : "2019-02-03T04:21:00Z", - "fltRouteSrc" : "FRA", - "fltRouteDest" : "HKG", - "estimatedArrival" : "2019-02-03T08:22:00Z", - "actions" : [ { - "actionAt" : "HKG", - "actionCode" : "Offload to Carousel at HKG", - "actionTime" : "2019-02-03T08:15:00Z" - }, { - "actionAt" : "FRA", - "actionCode" : "ONLOAD to HKG", - "actionTime" : "2019-02-03T07:36:00Z" - }, { - "actionAt" : "FRA", - "actionCode" : "OFFLOAD from FRA", - "actionTime" : "2019-02-03T07:23:00Z" - } ] - } ], - "lastSeenTimeGmt" : "2019-02-03T08:09:00Z", - "bagArrivalDate" : "2019-02-03T08:09:00Z" - } ] -); - - -### row 17 ### -INSERT INTO BaggageInfo VALUES( -1762311547917, -"Rosalia Triplett", -"F", -"368-769-5636", -"FH7G1W", -[ { - "id" : "79039899194559", - "tagNum" : "17657806215913", - "routing" : "JFK/IST/VIE", - "lastActionCode" : "OFFLOAD", - "lastActionDesc" : "OFFLOAD", - "lastSeenStation" : "VIE", - "flightLegs" : [ { - "flightNo" : "BM127", - "flightDate" : "2019-02-11T01:00:00Z", - "fltRouteSrc" : "JFK", - "fltRouteDest" : "IST", - "estimatedArrival" : "2019-02-11T17:00:00Z", - "actions" : [ { - "actionAt" : "JFK", - "actionCode" : "ONLOAD to IST", - "actionTime" : "2019-02-11T01:12:00Z" - }, { - "actionAt" : "JFK", - "actionCode" : "BagTag Scan at JFK", - "actionTime" : "2019-02-11T00:48:00Z" - }, { - "actionAt" : "JFK", - "actionCode" : "Checkin at JFK", - "actionTime" : "2019-02-10T23:39:00Z" - } ] - }, { - "flightNo" : "BM431", - "flightDate" : "2019-02-11T02:12:00Z", - "fltRouteSrc" : "IST", - "fltRouteDest" : "VIE", - "estimatedArrival" : "2019-02-12T07:12:00Z", - "actions" : [ { - "actionAt" : "VIE", - "actionCode" : "Offload to Carousel at VIE", - "actionTime" : "2019-02-12T07:08:00Z" - }, { - "actionAt" : "IST", - "actionCode" : "ONLOAD to VIE", - "actionTime" : "2019-02-12T07:52:00Z" - }, { - "actionAt" : "IST", - "actionCode" : "OFFLOAD from IST", - "actionTime" : "2019-02-12T07:31:00Z" - } ] - } ], - "lastSeenTimeGmt" : "2019-02-12T07:04:00Z", - "bagArrivalDate" : "2019-02-12T07:04:00Z" - } ] -); - - -### row 18 ### -INSERT INTO BaggageInfo VALUES( -1762357254392, -"Teena Colley", -"M", -"539-097-5220", -"TX1P7E", -[ { - "id" : "79039899153973", - "tagNum" : "17657806255823", - "routing" : "MSQ/FRA/HKG", - "lastActionCode" : "OFFLOAD", - "lastActionDesc" : "OFFLOAD", - "lastSeenStation" : "HKG", - "flightLegs" : [ { - "flightNo" : "BM365", - "flightDate" : "2019-02-13T07:00:00Z", - "fltRouteSrc" : "MSQ", - "fltRouteDest" : "FRA", - "estimatedArrival" : "2019-02-13T09:00:00Z", - "actions" : [ { - "actionAt" : "MSQ", - "actionCode" : "ONLOAD to FRA", - "actionTime" : "2019-02-13T07:17:00Z" - }, { - "actionAt" : "MSQ", - "actionCode" : "BagTag Scan at MSQ", - "actionTime" : "2019-02-13T06:52:00Z" - }, { - "actionAt" : "MSQ", - "actionCode" : "Checkin at MSQ", - "actionTime" : "2019-02-13T06:11:00Z" - } ] - }, { - "flightNo" : "BM313", - "flightDate" : "2019-02-13T07:17:00Z", - "fltRouteSrc" : "FRA", - "fltRouteDest" : "HKG", - "estimatedArrival" : "2019-02-13T11:18:00Z", - "actions" : [ { - "actionAt" : "HKG", - "actionCode" : "Offload to Carousel at HKG", - "actionTime" : "2019-02-13T11:15:00Z" - }, { - "actionAt" : "FRA", - "actionCode" : "ONLOAD to HKG", - "actionTime" : "2019-02-13T10:39:00Z" - }, { - "actionAt" : "FRA", - "actionCode" : "OFFLOAD from FRA", - "actionTime" : "2019-02-13T10:37:00Z" - } ] - } ], - "lastSeenTimeGmt" : "2019-02-13T11:15:00Z", - "bagArrivalDate" : "2019-02-13T11:15:00Z" - } ] -); - -### row 19 ### -INSERT INTO BaggageInfo VALUES( -1762390789239, -"Zina Christenson", -"M", -"987-210-3029", -"QB1O0J", -[ { - "id" : "79039899145397", - "tagNum" : "17657806228676", - "routing" : "MIA/LAX/MEL", - "lastActionCode" : "OFFLOAD", - "lastActionDesc" : "OFFLOAD", - "lastSeenStation" : "MEL", - "flightLegs" : [ { - "flightNo" : "BM604", - "flightDate" : "2019-02-04T00:00:00Z", - "fltRouteSrc" : "MIA", - "fltRouteDest" : "LAX", - "estimatedArrival" : "2019-02-04T05:00:00Z", - "actions" : [ { - "actionAt" : "MIA", - "actionCode" : "ONLOAD to LAX", - "actionTime" : "2019-02-04T00:12:00Z" - }, { - "actionAt" : "MIA", - "actionCode" : "BagTag Scan at MIA", - "actionTime" : "2019-02-03T23:52:00Z" - }, { - "actionAt" : "MIA", - "actionCode" : "Checkin at MIA", - "actionTime" : "2019-02-03T23:55:00Z" - } ] - }, { - "flightNo" : "BM667", - "flightDate" : "2019-02-04T00:12:00Z", - "fltRouteSrc" : "LAX", - "fltRouteDest" : "MEL", - "estimatedArrival" : "2019-02-04T10:14:00Z", - "actions" : [ { - "actionAt" : "MEL", - "actionCode" : "Offload to Carousel at MEL", - "actionTime" : "2019-02-04T10:06:00Z" - }, { - "actionAt" : "LAX", - "actionCode" : "ONLOAD to MEL", - "actionTime" : "2019-02-04T09:41:00Z" - }, { - "actionAt" : "LAX", - "actionCode" : "OFFLOAD from LAX", - "actionTime" : "2019-02-04T09:38:00Z" - } ] - } ], - "lastSeenTimeGmt" : "2019-02-04T10:08:00Z", - "bagArrivalDate" : "2019-02-04T10:08:00Z" - } ] -); - -### row 20 ### -INSERT INTO BaggageInfo VALUES( -1762340579411, -"Zulema Martindale", -"F", -"666-302-0028", -"CR2C8MY", -[ { - "id" : "79039899150438", - "tagNum" : "17657806288937", - "routing" : "MIA/LAX/MEL", - "lastActionCode" : "OFFLOAD", - "lastActionDesc" : "OFFLOAD", - "lastSeenStation" : "MEL", - "flightLegs" : [ { - "flightNo" : "BM604", - "flightDate" : "2019-02-25T10:00:00Z", - "fltRouteSrc" : "MIA", - "fltRouteDest" : "LAX", - "estimatedArrival" : "2019-02-25T15:00:00Z", - "actions" : [ { - "actionAt" : "MIA", - "actionCode" : "ONLOAD to LAX", - "actionTime" : "2019-02-25T10:23:00Z" - }, { - "actionAt" : "MIA", - "actionCode" : "BagTag Scan at MIA", - "actionTime" : "2019-02-25T09:54:00Z" - }, { - "actionAt" : "MIA", - "actionCode" : "Checkin at MIA", - "actionTime" : "2019-02-25T09:58:00Z" - } ] - }, { - "flightNo" : "BM667", - "flightDate" : "2019-02-25T10:23:00Z", - "fltRouteSrc" : "LAX", - "fltRouteDest" : "MEL", - "estimatedArrival" : "2019-02-25T20:25:00Z", - "actions" : [ { - "actionAt" : "MEL", - "actionCode" : "Offload to Carousel at MEL", - "actionTime" : "2019-02-25T20:16:00Z" - }, { - "actionAt" : "LAX", - "actionCode" : "ONLOAD to MEL", - "actionTime" : "2019-02-25T08:39:00Z" - }, { - "actionAt" : "LAX", - "actionCode" : "OFFLOAD from LAX", - "actionTime" : "2019-02-25T08:22:00Z" - } ] - } ], - "lastSeenTimeGmt" : "2019-02-25T20:15:00Z", - "bagArrivalDate" : "2019-02-25T20:15:00Z" - } ] -); - -### row 21 ### -INSERT INTO BaggageInfo VALUES( -1762320369957, -"Lorenzo Phil", -"M", -"364-610-4444", -"QI3V6Q", -[ { - "id" : "79039899187755", - "tagNum" : "17657806240001", - "routing" : "SFO/IST/ATH/JTR", - "lastActionCode" : "OFFLOAD", - "lastActionDesc" : "OFFLOAD", - "lastSeenStation" : "JTR", - "flightLegs" : [ { - "flightNo" : "BM318", - "flightDate" : "2019-03-12T03:00:00Z", - "fltRouteSrc" : "SFO", - "fltRouteDest" : "IST", - "estimatedArrival" : "2019-03-12T16:00:00Z", - "actions" : [ { - "actionAt" : "SFO", - "actionCode" : "ONLOAD to IST", - "actionTime" : "2019-03-12T03:11:00Z" - }, { - "actionAt" : "SFO", - "actionCode" : "BagTag Scan at SFO", - "actionTime" : "2019-03-12T02:49:00Z" - }, { - "actionAt" : "SFO", - "actionCode" : "Checkin at SFO", - "actionTime" : "2019-03-12T01:50:00Z" - } ] - }, { - "flightNo" : "BM696", - "flightDate" : "2019-03-12T04:11:00Z", - "fltRouteSrc" : "IST", - "fltRouteDest" : "ATH", - "estimatedArrival" : "2019-03-13T03:14:00Z", - "actions" : [ { - "actionAt" : "IST", - "actionCode" : "ONLOAD to ATH", - "actionTime" : "2019-03-13T04:10:00Z" - }, { - "actionAt" : "IST", - "actionCode" : "BagTag Scan at IST", - "actionTime" : "2019-03-13T03:56:00Z" - }, { - "actionAt" : "IST", - "actionCode" : "OFFLOAD from IST", - "actionTime" : "2019-03-13T03:59:00Z" - } ] - }, { - "flightNo" : "BM665", - "flightDate" : "2019-03-12T03:11:00Z", - "fltRouteSrc" : "ATH", - "fltRouteDest" : "JTR", - "estimatedArrival" : "2019-03-12T15:12:00Z", - "actions" : [ { - "actionAt" : "JTR", - "actionCode" : "Offload to Carousel at JTR", - "actionTime" : "2019-03-12T15:06:00Z" - }, { - "actionAt" : "ATH", - "actionCode" : "ONLOAD to JTR", - "actionTime" : "2019-03-12T14:16:00Z" - }, { - "actionAt" : "ATH", - "actionCode" : "OFFLOAD from ATH", - "actionTime" : "2019-03-12T14:13:00Z" - } ] - } ], - "lastSeenTimeGmt" : "2019-03-12T15:05:00Z", - "bagArrivalDate" : "2019-03-12T15:05:00Z" - }, - { - "id" : "79039899197755", - "tagNum" : "17657806340001", - "routing" : "SFO/IST/ATH/JTR", - "lastActionCode" : "OFFLOAD", - "lastActionDesc" : "OFFLOAD", - "lastSeenStation" : "JTR", - "flightLegs" : [ { - "flightNo" : "BM318", - "flightDate" : "2019-03-12T03:00:00Z", - "fltRouteSrc" : "SFO", - "fltRouteDest" : "IST", - "estimatedArrival" : "2019-03-12T16:40:00Z", - "actions" : [ { - "actionAt" : "SFO", - "actionCode" : "ONLOAD to IST", - "actionTime" : "2019-03-12T03:14:00Z" - }, { - "actionAt" : "SFO", - "actionCode" : "BagTag Scan at SFO", - "actionTime" : "2019-03-12T02:50:00Z" - }, { - "actionAt" : "SFO", - "actionCode" : "Checkin at SFO", - "actionTime" : "2019-03-12T01:58:00Z" - } ] - }, { - "flightNo" : "BM696", - "flightDate" : "2019-03-12T04:11:00Z", - "fltRouteSrc" : "IST", - "fltRouteDest" : "ATH", - "estimatedArrival" : "2019-03-13T03:18:00Z", - "actions" : [ { - "actionAt" : "IST", - "actionCode" : "ONLOAD to ATH", - "actionTime" : "2019-03-13T04:17:00Z" - }, { - "actionAt" : "IST", - "actionCode" : "BagTag Scan at IST", - "actionTime" : "2019-03-13T03:59:00Z" - }, { - "actionAt" : "IST", - "actionCode" : "OFFLOAD from IST", - "actionTime" : "2019-03-13T03:48:00Z" - } ] - }, { - "flightNo" : "BM665", - "flightDate" : "2019-03-12T03:11:00Z", - "fltRouteSrc" : "ATH", - "fltRouteDest" : "JTR", - "estimatedArrival" : "2019-03-12T15:12:00Z", - "actions" : [ { - "actionAt" : "JTR", - "actionCode" : "Offload to Carousel at JTR", - "actionTime" : "2019-03-12T15:06:00Z" - }, { - "actionAt" : "ATH", - "actionCode" : "ONLOAD to JTR", - "actionTime" : "2019-03-12T14:16:00Z" - }, { - "actionAt" : "ATH", - "actionCode" : "OFFLOAD from ATH", - "actionTime" : "2019-03-12T14:23:00Z" - } ] - } ], - "lastSeenTimeGmt" : "2019-03-12T16:05:00Z", - "bagArrivalDate" : "2019-03-12T16:25:00Z" - } ] -); \ No newline at end of file +### Begin Script ### +load -file baggageInfo.ddl +import -table baggageInfo -file baggageData.json +### End Script ### \ No newline at end of file diff --git a/examples-nosql-node-sdk/sqlexamples/AddBagData.js b/examples-nosql-node-sdk/sqlexamples/javascript/AddBagData.js similarity index 100% rename from examples-nosql-node-sdk/sqlexamples/AddBagData.js rename to examples-nosql-node-sdk/sqlexamples/javascript/AddBagData.js diff --git a/examples-nosql-node-sdk/sqlexamples/AddData.js b/examples-nosql-node-sdk/sqlexamples/javascript/AddData.js similarity index 100% rename from examples-nosql-node-sdk/sqlexamples/AddData.js rename to examples-nosql-node-sdk/sqlexamples/javascript/AddData.js diff --git a/examples-nosql-node-sdk/sqlexamples/AlterTable.js b/examples-nosql-node-sdk/sqlexamples/javascript/AlterTable.js similarity index 100% rename from examples-nosql-node-sdk/sqlexamples/AlterTable.js rename to examples-nosql-node-sdk/sqlexamples/javascript/AlterTable.js diff --git a/examples-nosql-node-sdk/sqlexamples/CreateTable.js b/examples-nosql-node-sdk/sqlexamples/javascript/CreateTable.js similarity index 100% rename from examples-nosql-node-sdk/sqlexamples/CreateTable.js rename to examples-nosql-node-sdk/sqlexamples/javascript/CreateTable.js diff --git a/examples-nosql-node-sdk/sqlexamples/GroupSortData.js b/examples-nosql-node-sdk/sqlexamples/javascript/GroupSortData.js similarity index 100% rename from examples-nosql-node-sdk/sqlexamples/GroupSortData.js rename to examples-nosql-node-sdk/sqlexamples/javascript/GroupSortData.js diff --git a/examples-nosql-node-sdk/sqlexamples/Indexes.js b/examples-nosql-node-sdk/sqlexamples/javascript/Indexes.js similarity index 100% rename from examples-nosql-node-sdk/sqlexamples/Indexes.js rename to examples-nosql-node-sdk/sqlexamples/javascript/Indexes.js diff --git a/examples-nosql-node-sdk/sqlexamples/ModifyData.js b/examples-nosql-node-sdk/sqlexamples/javascript/ModifyData.js similarity index 100% rename from examples-nosql-node-sdk/sqlexamples/ModifyData.js rename to examples-nosql-node-sdk/sqlexamples/javascript/ModifyData.js diff --git a/examples-nosql-node-sdk/sqlexamples/MultiDataOps.js b/examples-nosql-node-sdk/sqlexamples/javascript/MultiDataOps.js similarity index 100% rename from examples-nosql-node-sdk/sqlexamples/MultiDataOps.js rename to examples-nosql-node-sdk/sqlexamples/javascript/MultiDataOps.js diff --git a/examples-nosql-node-sdk/sqlexamples/MultiWrite.js b/examples-nosql-node-sdk/sqlexamples/javascript/MultiWrite.js similarity index 100% rename from examples-nosql-node-sdk/sqlexamples/MultiWrite.js rename to examples-nosql-node-sdk/sqlexamples/javascript/MultiWrite.js diff --git a/examples-nosql-node-sdk/sqlexamples/Namespaces.js b/examples-nosql-node-sdk/sqlexamples/javascript/Namespaces.js similarity index 100% rename from examples-nosql-node-sdk/sqlexamples/Namespaces.js rename to examples-nosql-node-sdk/sqlexamples/javascript/Namespaces.js diff --git a/examples-nosql-node-sdk/sqlexamples/QueryData.js b/examples-nosql-node-sdk/sqlexamples/javascript/QueryData.js similarity index 100% rename from examples-nosql-node-sdk/sqlexamples/QueryData.js rename to examples-nosql-node-sdk/sqlexamples/javascript/QueryData.js diff --git a/examples-nosql-node-sdk/sqlexamples/Regions.js b/examples-nosql-node-sdk/sqlexamples/javascript/Regions.js similarity index 100% rename from examples-nosql-node-sdk/sqlexamples/Regions.js rename to examples-nosql-node-sdk/sqlexamples/javascript/Regions.js diff --git a/examples-nosql-node-sdk/sqlexamples/SQLExpressions.js b/examples-nosql-node-sdk/sqlexamples/javascript/SQLExpressions.js similarity index 100% rename from examples-nosql-node-sdk/sqlexamples/SQLExpressions.js rename to examples-nosql-node-sdk/sqlexamples/javascript/SQLExpressions.js diff --git a/examples-nosql-node-sdk/sqlexamples/SQLFunctions.js b/examples-nosql-node-sdk/sqlexamples/javascript/SQLFunctions.js similarity index 100% rename from examples-nosql-node-sdk/sqlexamples/SQLFunctions.js rename to examples-nosql-node-sdk/sqlexamples/javascript/SQLFunctions.js diff --git a/examples-nosql-node-sdk/sqlexamples/SQLOperators.js b/examples-nosql-node-sdk/sqlexamples/javascript/SQLOperators.js similarity index 100% rename from examples-nosql-node-sdk/sqlexamples/SQLOperators.js rename to examples-nosql-node-sdk/sqlexamples/javascript/SQLOperators.js diff --git a/examples-nosql-node-sdk/sqlexamples/TableJoins.js b/examples-nosql-node-sdk/sqlexamples/javascript/TableJoins.js similarity index 100% rename from examples-nosql-node-sdk/sqlexamples/TableJoins.js rename to examples-nosql-node-sdk/sqlexamples/javascript/TableJoins.js diff --git a/examples-nosql-node-sdk/sqlexamples/typescript/AddBagData.ts b/examples-nosql-node-sdk/sqlexamples/typescript/AddBagData.ts new file mode 100644 index 0000000..733a3e1 --- /dev/null +++ b/examples-nosql-node-sdk/sqlexamples/typescript/AddBagData.ts @@ -0,0 +1,421 @@ +/* Copyright (c) 2023, 2024 Oracle and/or its affiliates. + * Licensed under the Universal Permissive License v 1.0 as shown at + * https://oss.oracle.com/licenses/upl/ + */ +'use strict'; + +import { NoSQLClient, Region } from 'oracle-nosqldb'; //Uncomment for Cloud +/* import { NoSQLClient, ServiceType } from 'oracle-nosqldb'; */ //Uncomment for On-Premise + +interface BagInt { + ticketNo: Long; + fullName: String; + gender: String; + contactPhone: String; + confNo: String; + bagInfo: JSON; +} +const TABLE_NAME = 'BaggageInfo'; +const bag1= ` +{ + "ticketNo":"1762376407826", + "fullName":"Dierdre Amador", + "gender":"M", + "contactPhone":"165-742-5715", + "confNo":"ZG8Z5N", + "bagInfo":[ { + "id" : "7903989918469", + "tagNum" : "17657806240229", + "routing" : "JFK/MAD", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "MAD", + "flightLegs" : [ { + "flightNo" : "BM495", + "flightDate" : "2019-03-07T07:00:00Z", + "fltRouteSrc" : "JFK", + "fltRouteDest" : "MAD", + "estimatedArrival" : "2019-03-07T14:00:00Z", + "actions" : [ { + "actionAt" : "MAD", + "actionCode" : "Offload to Carousel at MAD", + "actionTime" : "2019-03-07T13:54:00Z" + }, { + "actionAt" : "JFK", + "actionCode" : "ONLOAD to MAD", + "actionTime" : "2019-03-07T07:00:00Z" + }, { + "actionAt" : "JFK", + "actionCode" : "BagTag Scan at JFK", + "actionTime" : "2019-03-07T06:53:00Z" + }, { + "actionAt" : "JFK", + "actionCode" : "Checkin at JFK", + "actionTime" : "2019-03-07T05:03:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-03-07T13:51:00Z", + "bagArrivalDate" : "2019-03-07T13:51:00Z" + } ] +}` +const bag2= ` +{ + "ticketNo":"1762344493810", + "fullName":"Adam Phillips", + "gender":"M", + "contactPhone":"893-324-1064", + "confNo":"LE6J4Z", + "bagInfo":[ { + "id" : "79039899165297", + "tagNum" : "17657806255240", + "routing" : "MIA/LAX/MEL", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "MEL", + "flightLegs" : [ { + "flightNo" : "BM604", + "flightDate" : "2019-02-01T06:00:00Z", + "fltRouteSrc" : "MIA", + "fltRouteDest" : "LAX", + "estimatedArrival" : "2019-02-01T11:00:00Z", + "actions" : [ { + "actionAt" : "MIA", + "actionCode" : "ONLOAD to LAX", + "actionTime" : "2019-02-01T06:13:00Z" + }, { + "actionAt" : "MIA", + "actionCode" : "BagTag Scan at MIA", + "actionTime" : "2019-02-01T05:47:00Z" + }, { + "actionAt" : "MIA", + "actionCode" : "Checkin at MIA", + "actionTime" : "2019-02-01T04:38:00Z" + } ] + }, { + "flightNo" : "BM667", + "flightDate" : "2019-02-01T06:13:00Z", + "fltRouteSrc" : "LAX", + "fltRouteDest" : "MEL", + "estimatedArrival" : "2019-02-01T16:15:00Z", + "actions" : [ { + "actionAt" : "MEL", + "actionCode" : "Offload to Carousel at MEL", + "actionTime" : "2019-02-01T16:15:00Z" + }, { + "actionAt" : "LAX", + "actionCode" : "ONLOAD to MEL", + "actionTime" : "2019-02-01T15:35:00Z" + }, { + "actionAt" : "LAX", + "actionCode" : "OFFLOAD from LAX", + "actionTime" : "2019-02-01T15:18:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-02-01T16:13:00Z", + "bagArrivalDate" : "2019-02-01T16:13:00Z" + } ] +}` + +const bag3= ` +{ + "ticketNo":"1762341772625", + "fullName":"Gerard Greene", + "gender":"M", + "contactPhone":"395-837-3772", + "confNo":"MC0E7R", + "bagInfo":[ { + "id" : "79039899152842", + "tagNum" : "1765780626568", + "routing" : "SFO/IST/ATH/JTR", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "JTR", + "flightLegs" : [ { + "flightNo" : "BM318", + "flightDate" : "2019-03-07T04:00:00Z", + "fltRouteSrc" : "SFO", + "fltRouteDest" : "IST", + "estimatedArrival" : "2019-03-07T17:00:00Z", + "actions" : [ { + "actionAt" : "SFO", + "actionCode" : "ONLOAD to IST", + "actionTime" : "2019-03-07T04:08:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "BagTag Scan at SFO", + "actionTime" : "2019-03-07T03:53:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "Checkin at SFO", + "actionTime" : "2019-03-07T02:20:00Z" + } ] + }, { + "flightNo" : "BM696", + "flightDate" : "2019-03-07T05:08:00Z", + "fltRouteSrc" : "IST", + "fltRouteDest" : "ATH", + "estimatedArrival" : "2019-03-08T04:10:00Z", + "actions" : [ { + "actionAt" : "IST", + "actionCode" : "ONLOAD to ATH", + "actionTime" : "2019-03-08T04:55:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "BagTag Scan at IST", + "actionTime" : "2019-03-08T04:34:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "OFFLOAD from IST", + "actionTime" : "2019-03-08T04:47:00Z" + } ] + }, { + "flightNo" : "BM665", + "flightDate" : "2019-03-07T04:08:00Z", + "fltRouteSrc" : "ATH", + "fltRouteDest" : "JTR", + "estimatedArrival" : "2019-03-07T16:10:00Z", + "actions" : [ { + "actionAt" : "JTR", + "actionCode" : "Offload to Carousel at JTR", + "actionTime" : "2019-03-07T16:09:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "ONLOAD to JTR", + "actionTime" : "2019-03-07T15:51:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "OFFLOAD from ATH", + "actionTime" : "2019-03-07T15:43:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-03-07T16:01:00Z", + "bagArrivalDate" : "2019-03-07T16:01:00Z" + } ] +}` + +const bag4= ` +{ + "ticketNo":"1762320369957", + "fullName":"Lorenzo Phil", + "gender":"M", + "contactPhone":"364-610-4444", + "confNo":"QI3V6Q", + "bagInfo":[ { + "id" : "79039899187755", + "tagNum" : "17657806240001", + "routing" : "SFO/IST/ATH/JTR", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "JTR", + "flightLegs" : [ { + "flightNo" : "BM318", + "flightDate" : "2019-03-12T03:00:00Z", + "fltRouteSrc" : "SFO", + "fltRouteDest" : "IST", + "estimatedArrival" : "2019-03-12T16:00:00Z", + "actions" : [ { + "actionAt" : "SFO", + "actionCode" : "ONLOAD to IST", + "actionTime" : "2019-03-12T03:11:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "BagTag Scan at SFO", + "actionTime" : "2019-03-12T02:49:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "Checkin at SFO", + "actionTime" : "2019-03-12T01:50:00Z" + } ] + }, { + "flightNo" : "BM696", + "flightDate" : "2019-03-12T04:11:00Z", + "fltRouteSrc" : "IST", + "fltRouteDest" : "ATH", + "estimatedArrival" : "2019-03-13T03:14:00Z", + "actions" : [ { + "actionAt" : "IST", + "actionCode" : "ONLOAD to ATH", + "actionTime" : "2019-03-13T04:10:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "BagTag Scan at IST", + "actionTime" : "2019-03-13T03:56:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "OFFLOAD from IST", + "actionTime" : "2019-03-13T03:59:00Z" + } ] + }, { + "flightNo" : "BM665", + "flightDate" : "2019-03-12T03:11:00Z", + "fltRouteSrc" : "ATH", + "fltRouteDest" : "JTR", + "estimatedArrival" : "2019-03-12T15:12:00Z", + "actions" : [ { + "actionAt" : "JTR", + "actionCode" : "Offload to Carousel at JTR", + "actionTime" : "2019-03-12T15:06:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "ONLOAD to JTR", + "actionTime" : "2019-03-12T14:16:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "OFFLOAD from ATH", + "actionTime" : "2019-03-12T14:13:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-03-12T15:05:00Z", + "bagArrivalDate" : "2019-03-12T15:05:00Z" + }, + { + "id" : "79039899197755", + "tagNum" : "17657806340001", + "routing" : "SFO/IST/ATH/JTR", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "JTR", + "flightLegs" : [ { + "flightNo" : "BM318", + "flightDate" : "2019-03-12T03:00:00Z", + "fltRouteSrc" : "SFO", + "fltRouteDest" : "IST", + "estimatedArrival" : "2019-03-12T16:40:00Z", + "actions" : [ { + "actionAt" : "SFO", + "actionCode" : "ONLOAD to IST", + "actionTime" : "2019-03-12T03:14:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "BagTag Scan at SFO", + "actionTime" : "2019-03-12T02:50:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "Checkin at SFO", + "actionTime" : "2019-03-12T01:58:00Z" + } ] + }, { + "flightNo" : "BM696", + "flightDate" : "2019-03-12T04:11:00Z", + "fltRouteSrc" : "IST", + "fltRouteDest" : "ATH", + "estimatedArrival" : "2019-03-13T03:18:00Z", + "actions" : [ { + "actionAt" : "IST", + "actionCode" : "ONLOAD to ATH", + "actionTime" : "2019-03-13T04:17:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "BagTag Scan at IST", + "actionTime" : "2019-03-13T03:59:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "OFFLOAD from IST", + "actionTime" : "2019-03-13T03:48:00Z" + } ] + }, { + "flightNo" : "BM665", + "flightDate" : "2019-03-12T03:11:00Z", + "fltRouteSrc" : "ATH", + "fltRouteDest" : "JTR", + "estimatedArrival" : "2019-03-12T15:12:00Z", + "actions" : [ { + "actionAt" : "JTR", + "actionCode" : "Offload to Carousel at JTR", + "actionTime" : "2019-03-12T15:06:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "ONLOAD to JTR", + "actionTime" : "2019-03-12T14:16:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "OFFLOAD from ATH", + "actionTime" : "2019-03-12T14:23:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-03-12T16:05:00Z", + "bagArrivalDate" : "2019-03-12T16:25:00Z" + } ] +}` +/** + * Call the main function +**/ +doAddBagData(); + +async function doAddBagData() { + let handle; + try { + /* UNCOMMENT line of code below if you are using Oracle NoSQL Database + * Cloud service. Leave the line commented if you are using onPrem database */ + handle = await getConnection_cloud(); + /* UNCOMMENT line of code below if you are using onPremise Oracle NoSQL + * Database. Leave the line commented if you are using NoSQL Database + * Cloud Service + handle = await getConnection_onPrem(); */ + await createTable(handle); + let putResult = await handle.put(TABLE_NAME, JSON.parse(bag1)); + let putResult1 = await handle.put(TABLE_NAME, JSON.parse(bag2)); + let putResult2 = await handle.put(TABLE_NAME, JSON.parse(bag3)); + let putResult3 = await handle.put(TABLE_NAME, JSON.parse(bag4)); + console.log("Wrote records of BaggageInfo schema"); + } catch (error ) { + console.log(error); + } + finally { + if (handle) { + handle.close(); + } + } +} + +/* Create and return an instance of a NoSQLCLient object for cloud service */ +function getConnection_cloud() { + /* replace the placeholders for compartment and region with actual values.*/ + const Region = ``; + return new NoSQLClient({ + region: Region, + compartment: "", + }); +} +/* Create and return an instance of a NoSQLCLient object for onPremises */ +function getConnection_onPrem() { + /* replace the placeholder with the fullname of your host */ + const kvstore_endpoint = `http://:8080`; + return new NoSQLClient({ + serviceType: "KVSTORE", + endpoint: kvstore_endpoint + }); + /* if it is a secure store, comment the return statement above and + * uncomment the lines below and pass the credentials, username and password + return new NoSQLClient({ + "serviceType": "KVSTORE", + "endpoint": "", + "auth": { + "kvstore":{ + "user": "", + "password": "" + } + } + }); */ +} + +//creates a table +async function createTable(handle: NoSQLClient) { + const createDDL = `CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (ticketNo LONG, + fullName STRING, + gender STRING, + contactPhone STRING, + confNo STRING, + bagInfo JSON, + primary key(ticketNo))`; + console.log('Create table: ' + createDDL); + let res = await handle.tableDDL(createDDL, { + complete: true, + tableLimits: { + readUnits: 20, + writeUnits: 20, + storageGB: 1 + } + }); + console.log('Table created: ' + TABLE_NAME); +} diff --git a/examples-nosql-node-sdk/sqlexamples/typescript/AddData.ts b/examples-nosql-node-sdk/sqlexamples/typescript/AddData.ts new file mode 100644 index 0000000..8998983 --- /dev/null +++ b/examples-nosql-node-sdk/sqlexamples/typescript/AddData.ts @@ -0,0 +1,364 @@ +/* Copyright (c) 2023, 2024 Oracle and/or its affiliates. + * Licensed under the Universal Permissive License v 1.0 as shown at + * https://oss.oracle.com/licenses/upl/ + */ +'use strict'; +import { NoSQLClient, Region } from 'oracle-nosqldb'; //Uncomment for Cloud +/* import { NoSQLClient, ServiceType } from 'oracle-nosqldb'; */ //Uncomment for On-Premise +interface StreamInt { + acct_Id: Integer; + profile_name: String; + account_expiry: TIMESTAMP; + acct_data: JSON; +} + +const TABLE_NAME = 'stream_acct'; +const acct1= ` +{ +"acct_Id":1, +"profile_name":"AP", +"account_expiry":"2023-10-18", +"acct_data":{ + "firstName":"Adam", + "lastName":"Phillips", + "country":"Germany", + "contentStreamed":[ + { + "showName":"At the Ranch", + "showId":26, + "showtype":"tvseries", + "genres":[ + "action", + "crime", + "spanish" + ], + "numSeasons":4, + "seriesInfo":[ + { + "seasonNum":1, + "numEpisodes":2, + "episodes":[ + { + "episodeID":20, + "episodeName":"Season 1 episode 1", + "lengthMin":85, + "minWatched":85, + "date":"2022-04-18" + }, + { + "episodeID":30, + "lengthMin":60, + "episodeName":"Season 1 episode 2", + "minWatched":60, + "date":"2022 - 04 - 18 " + } + ] + }, + { + "seasonNum":2, + "numEpisodes":2, + "episodes":[ + { + "episodeID":40, + "episodeName":"Season 2 episode 1", + "lengthMin":50, + "minWatched":50, + "date":"2022-04-25" + }, + { + "episodeID":50, + "episodeName":"Season 2 episode 2", + "lengthMin":45, + "minWatched":30, + "date":"2022-04-27" + } + ] + }, + { + "seasonNum":3, + "numEpisodes":2, + "episodes":[ + { + "episodeID":60, + "episodeName":"Season 3 episode 1", + "lengthMin":50, + "minWatched":50, + "date":"2022-04-25" + }, + { + "episodeID":70, + "episodeName":"Season 3 episode 2", + "lengthMin":45, + "minWatched":30, + "date":"2022 - 04 - 27 " + } + ] + } + ] + }, + { + "showName":"Bienvenu", + "showId":15, + "showtype":"tvseries", + "genres":[ + "comedy", + "french" + ], + "numSeasons":2, + "seriesInfo":[ + { + "seasonNum":1, + "numEpisodes":2, + "episodes":[ + { + "episodeID":20, + "episodeName":"Bonjour", + "lengthMin":45, + "minWatched":45, + "date":"2022-03-07" + }, + { + "episodeID":30, + "episodeName":"Merci", + "lengthMin":42, + "minWatched":42, + "date":"2022-03-08" + } + ] } + ] } + ]} +}` +const acct2= ` +{ +"acct_Id":2, +"profile_name":"Adwi", +"account_expiry":"2023-10-31", +"acct_data":{ + "firstName":"Adelaide", + "lastName":"Willard", + "country":"France", + "contentStreamed":[ + { + "showName":"Bienvenu", + "showId":15, + "showtype":"tvseries", + "genres":[ + "comedy", + "french" + ], + "numSeasons":2, + "seriesInfo":[ + { + "seasonNum":1, + "numEpisodes":2, + "episodes":[ + { + "episodeID":22, + "episodeName":"Season 1 episode 1", + "lengthMin":65, + "minWatched":65, + "date":"2022-04-18" + }, + { + "episodeID":32, + "lengthMin":60, + "episodeName":"Season 1 episode 2", + "minWatched":60, + "date":"2022-04-18" + } + ] + }, + { + "seasonNum":2, + "numEpisodes":3, + "episodes":[ + { + "episodeID":42, + "episodeName":"Season 2 episode 1", + "lengthMin":50, + "minWatched":50, + "date":"2022-04-25" + } + ] + } + ] + } + ]} +} +` +const acct3= ` +{ +"acct_Id":3, +"profile_name":"Dee", +"account_expiry":"2023-11-28", +"acct_data":{ + "firstName":"Dierdre", + "lastName":"Amador", + "country":"USA", + "contentStreamed":[ + { + "showName":"Bienvenu", + "showId":15, + "showtype":"tvseries", + "genres":[ + "comedy", + "french" + ], + "numSeasons":2, + "seriesInfo":[ + { + "seasonNum":1, + "numEpisodes":2, + "episodes":[ + { + "episodeID":23, + "episodeName":"Season 1 episode 1", + "lengthMin":45, + "minWatched":40, + "date":"2022-08-18" + }, + { + "episodeID":33, + "lengthMin":60, + "episodeName":"Season 1 episode 2", + "minWatched":50, + "date":"2022-08-19" + } + ] + }, + { + "seasonNum":2, + "numEpisodes":3, + "episodes":[ + { + "episodeID":43, + "episodeName":"Season 2 episode 1", + "lengthMin":50, + "minWatched":50, + "date":"2022-08-25" + }, + { + "episodeID":53, + "episodeName":"Season 2 episode 2", + "lengthMin":45, + "minWatched":30, + "date":"2022-08-27" + } + ] + } + ] + }, + { + "showName":"Dane", + "showId":16, + "showtype":"tvseries", + "genres":[ + "comedy", + "drama", + "danish" + ], + "numSeasons":2, + "seriesInfo":[ + { + "seasonNum":1, + "numEpisodes":2, + "episodes":[ + { + "episodeID":24, + "episodeName":"Bonjour", + "lengthMin":45, + "minWatched":45, + "date":"2022-06-07" + }, + { + "episodeID":34, + "episodeName":"Merci", + "lengthMin":42, + "minWatched":42, + "date":"2022-06-08" + } + ] + } + ] + } + ]} +} +` +/* + * Call the main function + */ +doAddData(); + +async function doAddData() { + let handle; + try { + /* UNCOMMENT line of code below if you are using Oracle NoSQL Database + * Cloud service. Leave the line commented if you are using onPrem database*/ + handle = await getConnection_cloud(); + /* UNCOMMENT line of code below if you are using onPremise Oracle NoSQL + * Database. Leave the line commented if you are using NoSQL Database + * Cloud Service + handle = await getConnection_onPrem(); */ + await createTable(handle); + let putResult = await handle.put(TABLE_NAME, JSON.parse(acct1)); + let putResult1 = await handle.put(TABLE_NAME, JSON.parse(acct2)); + let putResult2 = await handle.put(TABLE_NAME, JSON.parse(acct3)); + console.log("Wrote records of acct stream schema"); + } catch (error ) { + console.log(error); + } + finally { + if (handle) { + handle.close(); + } + } +} + +/* Create and return an instance of a NoSQLCLient object for cloud service */ +function getConnection_cloud() { + /* replace the placeholders for compartment and region with actual values.*/ + const Region = ``; + return new NoSQLClient({ + region: Region, + compartment: "", + }); +} +/* Create and return an instance of a NoSQLCLient object for onPremises */ +function getConnection_onPrem() { + /* replace the placeholder with the fullname of your host */ + const kvstore_endpoint = `http://:8080`; + return new NoSQLClient({ + serviceType: "KVSTORE", + endpoint: kvstore_endpoint + }); + /* if it is a secure store, comment the return statement above and + * uncomment the lines below and pass the credentials, username and password + return new NoSQLClient({ + "serviceType": "KVSTORE", + "endpoint": "", + "auth": { + "kvstore":{ + "user": "", + "password": "" + } + } + }); */ +} +/* creates a table */ +async function createTable(handle: NoSQLClient) { + const createDDL = `CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (acct_Id INTEGER, + profile_name STRING, + account_expiry TIMESTAMP(1), + acct_data JSON, + primary key(acct_Id))`; + console.log('Create table: ' + createDDL); + let res = await handle.tableDDL(createDDL, { + complete: true, + tableLimits: { + readUnits: 20, + writeUnits: 20, + storageGB: 1 + } + }); + console.log('Table created: ' + TABLE_NAME); +} diff --git a/examples-nosql-node-sdk/sqlexamples/typescript/AlterTable.ts b/examples-nosql-node-sdk/sqlexamples/typescript/AlterTable.ts new file mode 100644 index 0000000..1c9af65 --- /dev/null +++ b/examples-nosql-node-sdk/sqlexamples/typescript/AlterTable.ts @@ -0,0 +1,97 @@ +/* Copyright (c) 2023, 2024 Oracle and/or its affiliates. + * Licensed under the Universal Permissive License v 1.0 as shown at + * https://oss.oracle.com/licenses/upl/ + */ +'use strict'; +import { NoSQLClient, Region } from 'oracle-nosqldb'; //Uncomment for Cloud +/* import { NoSQLClient, ServiceType } from 'oracle-nosqldb'; */ //Uncomment for On-Premise +const TABLE_NAME = 'stream_acct'; + +/* + * Call the main function + */ +doaltertable(); + +async function doaltertable() { + let handle; + try { + /* UNCOMMENT line of code below if you are using Oracle NoSQL Database + * Cloud service. Leave the line commented if you are using onPrem database*/ + handle = await getConnection_cloud(); + /* UNCOMMENT line of code below if you are using onPremise Oracle NoSQL + * Database. Leave the line commented if you are using NoSQL Database + * Cloud Service + handle = await getConnection_onPrem(); */ + await createTable(handle); + await alterTable(handle); + await dropTable(handle); + } catch (error ) { + console.log(error); + } + finally { + if (handle) { + handle.close(); + } + } +} + +/* Create and return an instance of a NoSQLCLient object for cloud service */ +function getConnection_cloud() { + /* replace the placeholders for compartment and region with actual values.*/ + const Region = ``; + return new NoSQLClient({ + region: Region, + compartment: "", + }); +} +/* Create and return an instance of a NoSQLCLient object for onPremises */ +function getConnection_onPrem() { + /* replace the placeholder with the fullname of your host */ + const kvstore_endpoint = `http://:8080`; + return new NoSQLClient({ + serviceType: "KVSTORE", + endpoint: kvstore_endpoint + }); + /* if it is a secure store, comment the return statement above and + * uncomment the lines below and pass the credentials, username and password + return new NoSQLClient({ + "serviceType": "KVSTORE", + "endpoint": "", + "auth": { + "kvstore":{ + "user": "", + "password": "" + } + } + }); */ +} +/* creates a table */ +async function createTable(handle: NoSQLClient) { + const createDDL = `CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (acct_Id INTEGER, + profile_name STRING, + account_expiry TIMESTAMP(1), + acct_data JSON, + primary key(acct_Id))`; + console.log('Create table: ' + createDDL); + let res = await handle.tableDDL(createDDL, { + complete: true, + tableLimits: { + readUnits: 20, + writeUnits: 20, + storageGB: 1 + } + }); + console.log('Table created: ' + TABLE_NAME); +} +/* alter a table and add a column */ +async function alterTable(handle: NoSQLClient) { + const alterDDL = `ALTER TABLE ${TABLE_NAME} (ADD acctname STRING)`; + let res = await handle.tableDDL(alterDDL); + console.log('Table altered: ' + TABLE_NAME); +} +/* drop a table */ +async function dropTable(handle: NoSQLClient) { + const dropDDL = `DROP TABLE ${TABLE_NAME}`; + let res = await handle.tableDDL(dropDDL); + console.log('Table dropped: ' + TABLE_NAME); +} diff --git a/examples-nosql-node-sdk/sqlexamples/typescript/CreateTable.ts b/examples-nosql-node-sdk/sqlexamples/typescript/CreateTable.ts new file mode 100644 index 0000000..9a12266 --- /dev/null +++ b/examples-nosql-node-sdk/sqlexamples/typescript/CreateTable.ts @@ -0,0 +1,81 @@ +/* Copyright (c) 2023, 2024 Oracle and/or its affiliates. + * Licensed under the Universal Permissive License v 1.0 as shown at + * https://oss.oracle.com/licenses/upl/ + */ +'use strict'; +import { NoSQLClient, Region } from 'oracle-nosqldb'; //Uncomment for Cloud +/* import { NoSQLClient, ServiceType } from 'oracle-nosqldb'; */ //Uncomment for On-Premise +const TABLE_NAME = 'stream_acct'; +/* + * Call the main function + */ +docreatetable(); + +async function docreatetable() { + let handle; + try { + /* UNCOMMENT line of code below if you are using Oracle NoSQL Database + * Cloud service. Leave the line commented if you are using onPrem database*/ + handle = await getConnection_cloud(); + /* UNCOMMENT line of code below if you are using onPremise Oracle NoSQL + * Database. Leave the line commented if you are using NoSQL Database + * Cloud Service + handle = await getConnection_onPrem(); */ + await createTable(handle); + } catch (error ) { + console.log(error); + } + finally { + if (handle) { + handle.close(); + } + } +} +/* Create and return an instance of a NoSQLCLient object for cloud service */ +function getConnection_cloud() { + /* replace the placeholders for compartment and region with actual values.*/ + const Region = ``; + return new NoSQLClient({ + region: Region, + compartment: "", + }); +} +/* Create and return an instance of a NoSQLCLient object for onPremises */ +function getConnection_onPrem() { + /* replace the placeholder with the fullname of your host */ + const kvstore_endpoint = `http://:8080`; + return new NoSQLClient({ + serviceType: "KVSTORE", + endpoint: kvstore_endpoint + }); + /* if it is a secure store, comment the return statement above and + * uncomment the lines below and pass the credentials, username and password + return new NoSQLClient({ + "serviceType": "KVSTORE", + "endpoint": "", + "auth": { + "kvstore":{ + "user": "", + "password": "" + } + } + }); */ +} +/* creates a table */ +async function createTable(handle: NoSQLClient) { + const createDDL = `CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (acct_Id INTEGER, + profile_name STRING, + account_expiry TIMESTAMP(1), + acct_data JSON, + primary key(acct_Id))`; + console.log('Create table: ' + createDDL); + let res = await handle.tableDDL(createDDL, { + complete: true, + tableLimits: { + readUnits: 20, + writeUnits: 20, + storageGB: 1 + } + }); + console.log('Table created: ' + TABLE_NAME); +} diff --git a/examples-nosql-node-sdk/sqlexamples/typescript/GroupSortData.ts b/examples-nosql-node-sdk/sqlexamples/typescript/GroupSortData.ts new file mode 100644 index 0000000..5850893 --- /dev/null +++ b/examples-nosql-node-sdk/sqlexamples/typescript/GroupSortData.ts @@ -0,0 +1,453 @@ +/* Copyright (c) 2023, 2024 Oracle and/or its affiliates. + * Licensed under the Universal Permissive License v 1.0 as shown at + * https://oss.oracle.com/licenses/upl/ + */ +'use strict'; + +import { NoSQLClient, Region } from 'oracle-nosqldb'; //Uncomment for Cloud +/* import { NoSQLClient, ServiceType } from 'oracle-nosqldb'; */ //Uncomment for On-Premise +const TABLE_NAME = 'BaggageInfo'; +interface BagInt { + ticketNo: Long; + fullName: String; + gender: String; + contactPhone: String; + confNo: String; + bagInfo: JSON; +} +const orderby_stmt = `SELECT bag.fullName, bag.bagInfo[].tagNum,bag.bagInfo[].lastSeenTimeGmt FROM BaggageInfo bag + WHERE bag.bagInfo[].lastSeenStation=any \"MEL\" ORDER BY bag.bagInfo[].lastSeenTimeGmt DESC` +const sortlimit_stmt = `SELECT $bag.fullName, $bag.bagInfo.tagNum, $flt_time FROM BaggageInfo $bag, + $bag.bagInfo[].lastSeenTimeGmt $flt_time + WHERE $bag.bagInfo[].lastSeenStation=any "JTR" + ORDER BY $flt_time LIMIT 4` +const groupsortlimit_stmt = `SELECT $flt_src as SOURCE, count(*) as COUNT FROM BaggageInfo $bag, + $bag.bagInfo.flightLegs[0].fltRouteSrc $flt_src GROUP BY $flt_src` + + +const bag1= ` +{ + "ticketNo":"1762376407826", + "fullName":"Dierdre Amador", + "gender":"M", + "contactPhone":"165-742-5715", + "confNo":"ZG8Z5N", + "bagInfo":[ { + "id" : "7903989918469", + "tagNum" : "17657806240229", + "routing" : "JFK/MAD", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "MAD", + "flightLegs" : [ { + "flightNo" : "BM495", + "flightDate" : "2019-03-07T07:00:00Z", + "fltRouteSrc" : "JFK", + "fltRouteDest" : "MAD", + "estimatedArrival" : "2019-03-07T14:00:00Z", + "actions" : [ { + "actionAt" : "MAD", + "actionCode" : "Offload to Carousel at MAD", + "actionTime" : "2019-03-07T13:54:00Z" + }, { + "actionAt" : "JFK", + "actionCode" : "ONLOAD to MAD", + "actionTime" : "2019-03-07T07:00:00Z" + }, { + "actionAt" : "JFK", + "actionCode" : "BagTag Scan at JFK", + "actionTime" : "2019-03-07T06:53:00Z" + }, { + "actionAt" : "JFK", + "actionCode" : "Checkin at JFK", + "actionTime" : "2019-03-07T05:03:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-03-07T13:51:00Z", + "bagArrivalDate" : "2019-03-07T13:51:00Z" + } ] +}` +const bag2= ` +{ + "ticketNo":"1762344493810", + "fullName":"Adam Phillips", + "gender":"M", + "contactPhone":"893-324-1064", + "confNo":"LE6J4Z", + "bagInfo":[ { + "id" : "79039899165297", + "tagNum" : "17657806255240", + "routing" : "MIA/LAX/MEL", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "MEL", + "flightLegs" : [ { + "flightNo" : "BM604", + "flightDate" : "2019-02-01T06:00:00Z", + "fltRouteSrc" : "MIA", + "fltRouteDest" : "LAX", + "estimatedArrival" : "2019-02-01T11:00:00Z", + "actions" : [ { + "actionAt" : "MIA", + "actionCode" : "ONLOAD to LAX", + "actionTime" : "2019-02-01T06:13:00Z" + }, { + "actionAt" : "MIA", + "actionCode" : "BagTag Scan at MIA", + "actionTime" : "2019-02-01T05:47:00Z" + }, { + "actionAt" : "MIA", + "actionCode" : "Checkin at MIA", + "actionTime" : "2019-02-01T04:38:00Z" + } ] + }, { + "flightNo" : "BM667", + "flightDate" : "2019-02-01T06:13:00Z", + "fltRouteSrc" : "LAX", + "fltRouteDest" : "MEL", + "estimatedArrival" : "2019-02-01T16:15:00Z", + "actions" : [ { + "actionAt" : "MEL", + "actionCode" : "Offload to Carousel at MEL", + "actionTime" : "2019-02-01T16:15:00Z" + }, { + "actionAt" : "LAX", + "actionCode" : "ONLOAD to MEL", + "actionTime" : "2019-02-01T15:35:00Z" + }, { + "actionAt" : "LAX", + "actionCode" : "OFFLOAD from LAX", + "actionTime" : "2019-02-01T15:18:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-02-01T16:13:00Z", + "bagArrivalDate" : "2019-02-01T16:13:00Z" + } ] +}` + +const bag3= ` +{ + "ticketNo":"1762341772625", + "fullName":"Gerard Greene", + "gender":"M", + "contactPhone":"395-837-3772", + "confNo":"MC0E7R", + "bagInfo":[ { + "id" : "79039899152842", + "tagNum" : "1765780626568", + "routing" : "SFO/IST/ATH/JTR", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "JTR", + "flightLegs" : [ { + "flightNo" : "BM318", + "flightDate" : "2019-03-07T04:00:00Z", + "fltRouteSrc" : "SFO", + "fltRouteDest" : "IST", + "estimatedArrival" : "2019-03-07T17:00:00Z", + "actions" : [ { + "actionAt" : "SFO", + "actionCode" : "ONLOAD to IST", + "actionTime" : "2019-03-07T04:08:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "BagTag Scan at SFO", + "actionTime" : "2019-03-07T03:53:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "Checkin at SFO", + "actionTime" : "2019-03-07T02:20:00Z" + } ] + }, { + "flightNo" : "BM696", + "flightDate" : "2019-03-07T05:08:00Z", + "fltRouteSrc" : "IST", + "fltRouteDest" : "ATH", + "estimatedArrival" : "2019-03-08T04:10:00Z", + "actions" : [ { + "actionAt" : "IST", + "actionCode" : "ONLOAD to ATH", + "actionTime" : "2019-03-08T04:55:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "BagTag Scan at IST", + "actionTime" : "2019-03-08T04:34:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "OFFLOAD from IST", + "actionTime" : "2019-03-08T04:47:00Z" + } ] + }, { + "flightNo" : "BM665", + "flightDate" : "2019-03-07T04:08:00Z", + "fltRouteSrc" : "ATH", + "fltRouteDest" : "JTR", + "estimatedArrival" : "2019-03-07T16:10:00Z", + "actions" : [ { + "actionAt" : "JTR", + "actionCode" : "Offload to Carousel at JTR", + "actionTime" : "2019-03-07T16:09:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "ONLOAD to JTR", + "actionTime" : "2019-03-07T15:51:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "OFFLOAD from ATH", + "actionTime" : "2019-03-07T15:43:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-03-07T16:01:00Z", + "bagArrivalDate" : "2019-03-07T16:01:00Z" + } ] +}` + +const bag4= ` +{ + "ticketNo":"1762320369957", + "fullName":"Lorenzo Phil", + "gender":"M", + "contactPhone":"364-610-4444", + "confNo":"QI3V6Q", + "bagInfo":[ { + "id" : "79039899187755", + "tagNum" : "17657806240001", + "routing" : "SFO/IST/ATH/JTR", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "JTR", + "flightLegs" : [ { + "flightNo" : "BM318", + "flightDate" : "2019-03-12T03:00:00Z", + "fltRouteSrc" : "SFO", + "fltRouteDest" : "IST", + "estimatedArrival" : "2019-03-12T16:00:00Z", + "actions" : [ { + "actionAt" : "SFO", + "actionCode" : "ONLOAD to IST", + "actionTime" : "2019-03-12T03:11:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "BagTag Scan at SFO", + "actionTime" : "2019-03-12T02:49:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "Checkin at SFO", + "actionTime" : "2019-03-12T01:50:00Z" + } ] + }, { + "flightNo" : "BM696", + "flightDate" : "2019-03-12T04:11:00Z", + "fltRouteSrc" : "IST", + "fltRouteDest" : "ATH", + "estimatedArrival" : "2019-03-13T03:14:00Z", + "actions" : [ { + "actionAt" : "IST", + "actionCode" : "ONLOAD to ATH", + "actionTime" : "2019-03-13T04:10:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "BagTag Scan at IST", + "actionTime" : "2019-03-13T03:56:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "OFFLOAD from IST", + "actionTime" : "2019-03-13T03:59:00Z" + } ] + }, { + "flightNo" : "BM665", + "flightDate" : "2019-03-12T03:11:00Z", + "fltRouteSrc" : "ATH", + "fltRouteDest" : "JTR", + "estimatedArrival" : "2019-03-12T15:12:00Z", + "actions" : [ { + "actionAt" : "JTR", + "actionCode" : "Offload to Carousel at JTR", + "actionTime" : "2019-03-12T15:06:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "ONLOAD to JTR", + "actionTime" : "2019-03-12T14:16:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "OFFLOAD from ATH", + "actionTime" : "2019-03-12T14:13:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-03-12T15:05:00Z", + "bagArrivalDate" : "2019-03-12T15:05:00Z" + }, + { + "id" : "79039899197755", + "tagNum" : "17657806340001", + "routing" : "SFO/IST/ATH/JTR", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "JTR", + "flightLegs" : [ { + "flightNo" : "BM318", + "flightDate" : "2019-03-12T03:00:00Z", + "fltRouteSrc" : "SFO", + "fltRouteDest" : "IST", + "estimatedArrival" : "2019-03-12T16:40:00Z", + "actions" : [ { + "actionAt" : "SFO", + "actionCode" : "ONLOAD to IST", + "actionTime" : "2019-03-12T03:14:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "BagTag Scan at SFO", + "actionTime" : "2019-03-12T02:50:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "Checkin at SFO", + "actionTime" : "2019-03-12T01:58:00Z" + } ] + }, { + "flightNo" : "BM696", + "flightDate" : "2019-03-12T04:11:00Z", + "fltRouteSrc" : "IST", + "fltRouteDest" : "ATH", + "estimatedArrival" : "2019-03-13T03:18:00Z", + "actions" : [ { + "actionAt" : "IST", + "actionCode" : "ONLOAD to ATH", + "actionTime" : "2019-03-13T04:17:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "BagTag Scan at IST", + "actionTime" : "2019-03-13T03:59:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "OFFLOAD from IST", + "actionTime" : "2019-03-13T03:48:00Z" + } ] + }, { + "flightNo" : "BM665", + "flightDate" : "2019-03-12T03:11:00Z", + "fltRouteSrc" : "ATH", + "fltRouteDest" : "JTR", + "estimatedArrival" : "2019-03-12T15:12:00Z", + "actions" : [ { + "actionAt" : "JTR", + "actionCode" : "Offload to Carousel at JTR", + "actionTime" : "2019-03-12T15:06:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "ONLOAD to JTR", + "actionTime" : "2019-03-12T14:16:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "OFFLOAD from ATH", + "actionTime" : "2019-03-12T14:23:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-03-12T16:05:00Z", + "bagArrivalDate" : "2019-03-12T16:25:00Z" + } ] +}` +/** + * Call the main function + **/ +doSQLOperators(); + +async function doSQLOperators() { + let handle; + try { + /* UNCOMMENT line of code below if you are using Oracle NoSQL Database + * Cloud service. Leave the line commented if you are using onPrem database */ + handle = await getConnection_cloud(); + /* UNCOMMENT line of code below if you are using onPremise Oracle NoSQL + * Database. Leave the line commented if you are using NoSQL Database + * Cloud Service + handle = await getConnection_onPrem(); */ + await createTable(handle); + let putResult = await handle.put(TABLE_NAME, JSON.parse(bag1)); + let putResult1 = await handle.put(TABLE_NAME, JSON.parse(bag2)); + let putResult2 = await handle.put(TABLE_NAME, JSON.parse(bag3)); + let putResult3 = await handle.put(TABLE_NAME, JSON.parse(bag4)); + console.log("Wrote records of BaggageInfo schema"); + console.log("Using ORDER BY to sort data"); + await fetchData(handle,orderby_stmt); + + console.log("Using ORDER BY and LIMIT to sort and limit data"); + await fetchData(handle,sortlimit_stmt); + + console.log("Using GROUP BY, ORDER BY and LIMIT to group, sort and limit data"); + await fetchData(handle,groupsortlimit_stmt); + } catch (error ) { + console.log(error); + } + finally { + if (handle) { + handle.close(); + } + } +} + +/* Create and return an instance of a NoSQLCLient object for cloud service */ +function getConnection_cloud() { + /* replace the placeholders for compartment and region with actual values.*/ + const Region = ``; + return new NoSQLClient({ + region: Region, + compartment: "", + }); +} +/* Create and return an instance of a NoSQLCLient object for onPremises */ +function getConnection_onPrem() { + /* replace the placeholder with the fullname of your host */ + const kvstore_endpoint = `http://:8080`; + return new NoSQLClient({ + serviceType: "KVSTORE", + endpoint: kvstore_endpoint + }); + /* if it is a secure store, comment the return statement above and + * uncomment the lines below and pass the credentials, username and password + return new NoSQLClient({ + "serviceType": "KVSTORE", + "endpoint": "", + "auth": { + "kvstore":{ + "user": "", + "password": "" + } + } + }); */ +} + +//creates a table +async function createTable(handle: NoSQLClient) { + const createDDL = `CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (ticketNo LONG, + fullName STRING, + gender STRING, + contactPhone STRING, + confNo STRING, + bagInfo JSON, + primary key(ticketNo))`; + console.log('Create table: ' + createDDL); + let res = await handle.tableDDL(createDDL, { + complete: true, + tableLimits: { + readUnits: 20, + writeUnits: 20, + storageGB: 1 + } + }); + console.log('Table created: ' + TABLE_NAME); +} +//fetches data from the table +async function fetchData(handle: NoSQLClient,querystmt: string) { + const opt = {}; + try { + do { + const result = await handle.query(querystmt, opt); + for(let row of result.rows) { + console.log(' %O', row); + } + opt.continuationKey = result.continuationKey; + } while(opt.continuationKey); + } catch(error) { + console.error(' Error: ' + error.message); + } +} diff --git a/examples-nosql-node-sdk/sqlexamples/typescript/Indexes.ts b/examples-nosql-node-sdk/sqlexamples/typescript/Indexes.ts new file mode 100644 index 0000000..dc913a0 --- /dev/null +++ b/examples-nosql-node-sdk/sqlexamples/typescript/Indexes.ts @@ -0,0 +1,96 @@ +/* Copyright (c) 2023, 2024 Oracle and/or its affiliates. + * Licensed under the Universal Permissive License v 1.0 as shown at + * https://oss.oracle.com/licenses/upl/ + */ +'use strict'; +import { NoSQLClient, Region } from 'oracle-nosqldb'; //Uncomment for Cloud +/* import { NoSQLClient, ServiceType } from 'oracle-nosqldb'; */ //Uncomment for On-Premise +const TABLE_NAME = 'stream_acct'; + +/* + * Call the main function + */ +doindexes(); + +async function doindexes() { + let handle; + try { + /* UNCOMMENT line of code below if you are using Oracle NoSQL Database + * Cloud service. Leave the line commented if you are using onPrem database*/ + handle = await getConnection_cloud(); + /* UNCOMMENT line of code below if you are using onPremise Oracle NoSQL + * Database. Leave the line commented if you are using NoSQL Database + * Cloud Service + handle = await getConnection_onPrem(); */ + await createTable(handle); + await createIndex(handle); + await dropIndex(handle); + } catch (error ) { + console.log(error); + } + finally { + if (handle) { + handle.close(); + } + } +} +/* Create and return an instance of a NoSQLCLient object for cloud service */ +function getConnection_cloud() { + /* replace the placeholders for compartment and region with actual values.*/ + const Region = ``; + return new NoSQLClient({ + region: Region, + compartment: "", + }); +} +/* Create and return an instance of a NoSQLCLient object for onPremises */ +function getConnection_onPrem() { + /* replace the placeholder with the fullname of your host */ + const kvstore_endpoint = `http://:8080`; + return new NoSQLClient({ + serviceType: "KVSTORE", + endpoint: kvstore_endpoint + }); + /* if it is a secure store, comment the return statement above and + * uncomment the lines below and pass the credentials, username and password + return new NoSQLClient({ + "serviceType": "KVSTORE", + "endpoint": "", + "auth": { + "kvstore":{ + "user": "", + "password": "" + } + } + }); */ +} +/* creates a table */ +async function createTable(handle: NoSQLClient) { + const createDDL = `CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (acct_Id INTEGER, + profile_name STRING, + account_expiry TIMESTAMP(1), + acct_data JSON, + primary key(acct_Id))`; + console.log('Create table: ' + createDDL); + let res = await handle.tableDDL(createDDL, { + complete: true, + tableLimits: { + readUnits: 20, + writeUnits: 20, + storageGB: 1 + } + }); + console.log('Table created: ' + TABLE_NAME); +} +/* creates an index */ +async function createIndex(handle: NoSQLClient) { + const crtindDDL = `CREATE INDEX acct_episodes ON ${TABLE_NAME}(acct_data.contentStreamed[].seriesInfo[].episodes[] AS ANYATOMIC)`; + let res = await handle.tableDDL(crtindDDL); + console.log('Index acct_episodes is created on table:' + TABLE_NAME); +} +/* drops an index */ +async function dropIndex(handle: NoSQLClient) { + const dropindDDL = `DROP INDEX acct_episodes ON ${TABLE_NAME}`; + let res = await handle.tableDDL(dropindDDL); + console.log('Index acct_episodes is dropped from table: ' + TABLE_NAME); +} diff --git a/examples-nosql-node-sdk/sqlexamples/typescript/ModifyData.ts b/examples-nosql-node-sdk/sqlexamples/typescript/ModifyData.ts new file mode 100644 index 0000000..2e27699 --- /dev/null +++ b/examples-nosql-node-sdk/sqlexamples/typescript/ModifyData.ts @@ -0,0 +1,536 @@ +/* Copyright (c) 2023, 2024 Oracle and/or its affiliates. + * Licensed under the Universal Permissive License v 1.0 as shown at + * https://oss.oracle.com/licenses/upl/ + */ +'use strict'; +import { NoSQLClient, Region } from 'oracle-nosqldb'; //Uncomment for Cloud +/* import { NoSQLClient, ServiceType } from 'oracle-nosqldb'; */ //Uncomment for On-Premise +const TABLE_NAME = 'stream_acct'; + +interface StreamInt { + acct_Id: Integer; + profile_name: String; + account_expiry: TIMESTAMP; + acct_data: JSON; +} +const acct1= ` +{ +"acct_Id":1, +"profile_name":"AP", +"account_expiry":"2023-10-18", +"acct_data":{ + "firstName":"Adam", + "lastName":"Phillips", + "country":"Germany", + "contentStreamed":[ + { + "showName":"At the Ranch", + "showId":26, + "showtype":"tvseries", + "genres":[ + "action", + "crime", + "spanish" + ], + "numSeasons":4, + "seriesInfo":[ + { + "seasonNum":1, + "numEpisodes":2, + "episodes":[ + { + "episodeID":20, + "episodeName":"Season 1 episode 1", + "lengthMin":85, + "minWatched":85, + "date":"2022-04-18" + }, + { + "episodeID":30, + "lengthMin":60, + "episodeName":"Season 1 episode 2", + "minWatched":60, + "date":"2022 - 04 - 18 " + } + ] + }, + { + "seasonNum":2, + "numEpisodes":2, + "episodes":[ + { + "episodeID":40, + "episodeName":"Season 2 episode 1", + "lengthMin":50, + "minWatched":50, + "date":"2022-04-25" + }, + { + "episodeID":50, + "episodeName":"Season 2 episode 2", + "lengthMin":45, + "minWatched":30, + "date":"2022-04-27" + } + ] + }, + { + "seasonNum":3, + "numEpisodes":2, + "episodes":[ + { + "episodeID":60, + "episodeName":"Season 3 episode 1", + "lengthMin":50, + "minWatched":50, + "date":"2022-04-25" + }, + { + "episodeID":70, + "episodeName":"Season 3 episode 2", + "lengthMin":45, + "minWatched":30, + "date":"2022 - 04 - 27 " + } + ] + } + ] + }, + { + "showName":"Bienvenu", + "showId":15, + "showtype":"tvseries", + "genres":[ + "comedy", + "french" + ], + "numSeasons":2, + "seriesInfo":[ + { + "seasonNum":1, + "numEpisodes":2, + "episodes":[ + { + "episodeID":20, + "episodeName":"Bonjour", + "lengthMin":45, + "minWatched":45, + "date":"2022-03-07" + }, + { + "episodeID":30, + "episodeName":"Merci", + "lengthMin":42, + "minWatched":42, + "date":"2022-03-08" + } + ] } + ] } + ]} +}` +const acct2= ` +{ +"acct_Id":2, +"profile_name":"Adwi", +"account_expiry":"2023-10-31", +"acct_data":{ + "firstName":"Adelaide", + "lastName":"Willard", + "country":"France", + "contentStreamed":[ + { + "showName":"Bienvenu", + "showId":15, + "showtype":"tvseries", + "genres":[ + "comedy", + "french" + ], + "numSeasons":2, + "seriesInfo":[ + { + "seasonNum":1, + "numEpisodes":2, + "episodes":[ + { + "episodeID":22, + "episodeName":"Season 1 episode 1", + "lengthMin":65, + "minWatched":65, + "date":"2022-04-18" + }, + { + "episodeID":32, + "lengthMin":60, + "episodeName":"Season 1 episode 2", + "minWatched":60, + "date":"2022-04-18" + } + ] + }, + { + "seasonNum":2, + "numEpisodes":3, + "episodes":[ + { + "episodeID":42, + "episodeName":"Season 2 episode 1", + "lengthMin":50, + "minWatched":50, + "date":"2022-04-25" + } + ] + } + ] + } + ]} +} +` +const acct3= ` +{ +"acct_Id":3, +"profile_name":"Dee", +"account_expiry":"2023-11-28", +"acct_data":{ + "firstName":"Dierdre", + "lastName":"Amador", + "country":"USA", + "contentStreamed":[ + { + "showName":"Bienvenu", + "showId":15, + "showtype":"tvseries", + "genres":[ + "comedy", + "french" + ], + "numSeasons":2, + "seriesInfo":[ + { + "seasonNum":1, + "numEpisodes":2, + "episodes":[ + { + "episodeID":23, + "episodeName":"Season 1 episode 1", + "lengthMin":45, + "minWatched":40, + "date":"2022-08-18" + }, + { + "episodeID":33, + "lengthMin":60, + "episodeName":"Season 1 episode 2", + "minWatched":50, + "date":"2022-08-19" + } + ] + }, + { + "seasonNum":2, + "numEpisodes":3, + "episodes":[ + { + "episodeID":43, + "episodeName":"Season 2 episode 1", + "lengthMin":50, + "minWatched":50, + "date":"2022-08-25" + }, + { + "episodeID":53, + "episodeName":"Season 2 episode 2", + "lengthMin":45, + "minWatched":30, + "date":"2022-08-27" + } + ] + } + ] + }, + { + "showName":"Dane", + "showId":16, + "showtype":"tvseries", + "genres":[ + "comedy", + "drama", + "danish" + ], + "numSeasons":2, + "seriesInfo":[ + { + "seasonNum":1, + "numEpisodes":2, + "episodes":[ + { + "episodeID":24, + "episodeName":"Bonjour", + "lengthMin":45, + "minWatched":45, + "date":"2022-06-07" + }, + { + "episodeID":34, + "episodeName":"Merci", + "lengthMin":42, + "minWatched":42, + "date":"2022-06-08" + } + ] + } + ] + } + ]} +} +` +const upsert_row = `UPSERT INTO stream_acct VALUES +( + 1, + "AP", + "2023-10-18", + { + "firstName": "Adam", + "lastName": "Phillips", + "country": "Germany", + "contentStreamed": [{ + "showName": "At the Ranch", + "showId": 26, + "showtype": "tvseries", + "genres": ["action", "crime", "spanish"], + "numSeasons": 4, + "seriesInfo": [{ + "seasonNum": 1, + "numEpisodes": 2, + "episodes": [{ + "episodeID": 20, + "episodeName": "Season 1 episode 1", + "lengthMin": 75, + "minWatched": 75, + "date": "2022-04-18" + }, + { + "episodeID": 30, + "lengthMin": 60, + "episodeName": "Season 1 episode 2", + "minWatched": 40, + "date": "2022 - 04 - 18 " + }] + }, + { + "seasonNum": 2, + "numEpisodes": 2, + "episodes": [{ + "episodeID": 40, + "episodeName": "Season 2 episode 1", + "lengthMin": 40, + "minWatched": 30, + "date": "2022-04-25" + }, + { + "episodeID": 50, + "episodeName": "Season 2 episode 2", + "lengthMin": 45, + "minWatched": 30, + "date": "2022-04-27" + }] + }, + { + "seasonNum": 3, + "numEpisodes": 2, + "episodes": [{ + "episodeID": 60, + "episodeName": "Season 3 episode 1", + "lengthMin": 20, + "minWatched": 20, + "date": "2022-04-25" + }, + { + "episodeID": 70, + "episodeName": "Season 3 episode 2", + "lengthMin": 45, + "minWatched": 30, + "date": "2022 - 04 - 27 " + }] + }] + }, + { + "showName": "Bienvenu", + "showId": 15, + "showtype": "tvseries", + "genres": ["comedy", "french"], + "numSeasons": 2, + "seriesInfo": [{ + "seasonNum": 1, + "numEpisodes": 2, + "episodes": [{ + "episodeID": 20, + "episodeName": "Bonjour", + "lengthMin": 45, + "minWatched": 45, + "date": "2022-03-07" + }, + { + "episodeID": 30, + "episodeName": "Merci", + "lengthMin": 42, + "minWatched": 42, + "date": "2022-03-08" + }] + }] + }] + }) RETURNING *` + +const stmt1 = 'select * from stream_acct'; +const stmt2 = 'select account_expiry, acct.acct_data.lastName, acct.acct_data.contentStreamed[].showName from stream_acct acct where acct_id=1'; +const updt_stmt = 'UPDATE stream_acct SET account_expiry="2023-12-28T00:00:00.0Z" WHERE acct_Id=3' + +const upd_json_addnode = `UPDATE stream_acct acct1 ADD acct1.acct_data.contentStreamed.seriesInfo[1].episodes { + "date" : "2022-04-26", + "episodeID" : 43, + "episodeName" : "Season 2 episode 2", + "lengthMin" : 45, + "minWatched" : 45} WHERE acct_Id=2 RETURNING *` +const upd_json_delnode = 'UPDATE stream_acct acct1 REMOVE acct1.acct_data.contentStreamed.seriesInfo[1].episodes[1] WHERE acct_Id=2 RETURNING *' +const del_stmt = 'DELETE FROM stream_acct acct1 WHERE acct1.acct_data.firstName="Adelaide" AND acct1.acct_data.lastName="Willard"' +/** + * Call the main function + **/ +doModifyData(); + +async function doModifyData() { + let handle; + try { + /* UNCOMMENT line of code below if you are using Oracle NoSQL Database + * Cloud service. Leave the line commented if you are using onPrem database */ + handle = await getConnection_cloud(); + /* UNCOMMENT line of code below if you are using onPremise Oracle NoSQL + * Database. Leave the line commented if you are using NoSQL Database + * Cloud Service + handle = await getConnection_onPrem(); */ + await createTable(handle); + let putResult = await handle.put(TABLE_NAME, JSON.parse(acct1)); + let putResult1 = await handle.put(TABLE_NAME, JSON.parse(acct2)); + let putResult2 = await handle.put(TABLE_NAME, JSON.parse(acct3)); + console.log("Wrote records of acct stream schema"); + await upsertData(handle,upsert_row); + console.log("Upsert data into table"); + await updateData(handle,updt_stmt); + console.log("Data updated in the table"); + await updateData(handle,upd_json_addnode); + console.log("New data node added in the table"); + await updateData(handle,upd_json_delnode); + console.log("New Data node removed from the table"); + await delRow(handle); + console.log("Row deleted based on primary key"); + await deleteRows(handle,del_stmt); + console.log("Rows deleted"); + } catch (error ) { + console.log(error); + } + finally { + if (handle) { + handle.close(); + } + } +} + +/* Create and return an instance of a NoSQLCLient object for cloud service */ +function getConnection_cloud() { + /* replace the placeholders for compartment and region with actual values.*/ + const Region = ``; + return new NoSQLClient({ + region: Region, + compartment: "", + }); +} +/* Create and return an instance of a NoSQLCLient object for onPremises */ +function getConnection_onPrem() { + /* replace the placeholder with the fullname of your host */ + const kvstore_endpoint = `http://:8080`; + return new NoSQLClient({ + serviceType: "KVSTORE", + endpoint: kvstore_endpoint + }); + /* if it is a secure store, comment the return statement above and + * uncomment the lines below and pass the credentials, username and password + return new NoSQLClient({ + "serviceType": "KVSTORE", + "endpoint": "", + "auth": { + "kvstore":{ + "user": "", + "password": "" + } + } + }); */ +} +/*creates a table*/ +async function createTable(handle: NoSQLClient) { + const createDDL = `CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (acct_Id INTEGER, + profile_name STRING, + account_expiry TIMESTAMP(1), + acct_data JSON, + primary key(acct_Id))`; + console.log('Create table: ' + createDDL); + let res = await handle.tableDDL(createDDL, { + complete: true, + tableLimits: { + readUnits: 20, + writeUnits: 20, + storageGB: 1 + } + }); + console.log('Table created: ' + TABLE_NAME); +} +/*upserts data in the table*/ +async function upsertData(handle: NoSQLClient,querystmt: string) { + const opt = {}; + try { + do { + const result = await handle.query(querystmt, opt); + for(let row of result.rows) { + console.log(' %O', row); + } + opt.continuationKey = result.continuationKey; + } while(opt.continuationKey); + } catch(error) { + console.error(' Error: ' + error.message); + } +} +/*updates data in the table*/ +async function updateData(handle: NoSQLClient,querystmt: string) { + const opt = {}; + try { + do { + const result = await handle.query(querystmt, opt); + opt.continuationKey = result.continuationKey; + } while(opt.continuationKey); + } catch(error) { + console.error(' Error: ' + error.message); + } +} + +/*delete row based on primary key*/ +async function delRow(handle: NoSQLClient) { + try { + /* Unconditional delete, should succeed.*/ + var result = await handle.delete(TABLE_NAME, { acct_Id: 1 }); + /* Expected output: delete succeeded*/ + console.log('delete ' + result.success ? 'succeeded' : 'failed'); + } catch(error) { + console.error(' Error: ' + error.message); + } +} +/*deletes data based on a filter conditioin */ +async function deleteRows(handle: NoSQLClient,querystmt: string) { + const opt = {}; + try { + do { + const result = await handle.query(querystmt, opt); + opt.continuationKey = result.continuationKey; + } while(opt.continuationKey); + } catch(error) { + console.error(' Error: ' + error.message); + } +} diff --git a/examples-nosql-node-sdk/sqlexamples/typescript/MultiDataOps.ts b/examples-nosql-node-sdk/sqlexamples/typescript/MultiDataOps.ts new file mode 100644 index 0000000..527bd01 --- /dev/null +++ b/examples-nosql-node-sdk/sqlexamples/typescript/MultiDataOps.ts @@ -0,0 +1,156 @@ +/* Copyright (c) 2023, 2024 Oracle and/or its affiliates. + * Licensed under the Universal Permissive License v 1.0 as shown at + * https://oss.oracle.com/licenses/upl/ + */ +'use strict'; +import { NoSQLClient, Region } from 'oracle-nosqldb'; //Uncomment for Cloud +/* import { NoSQLClient, ServiceType } from 'oracle-nosqldb'; */ //Uncomment for On-Premise + +interface AddressInt { + id: Integer; + address_line1: String; + address_line2: String; + pin: Integer; +} +const TABLE_NAME = 'examplesAddress'; +const add1= ` +{ + "id":1, + "address_line1":"10 Red Street", + "address_line2":"Apt 3", + "pin":1234567 +}` +const add2= ` +{ + "id":2, + "address_line1":"2 Green Street", + "address_line2":"Street 9", + "pin":1234567 +}` +const add3= ` +{ + "id":3, + "address_line1":"5 Blue Ave", + "address_line2":"Floor 9", + "pin":1234567 +}` +const add4= ` +{ + "id":4, + "address_line1":"9 Yellow Boulevard", + "address_line2":"Apt 3", + "pin":87654321 +}` +const stmt1 = 'select * from examplesAddress'; + + +/** + * Call the main function + **/ +doMultiDataOps(); + +async function doMultiDataOps() { + let handle; + try { + /* UNCOMMENT line of code below if you are using Oracle NoSQL Database + * Cloud service. Leave the line commented if you are using onPrem database*/ + handle = await getConnection_cloud(); + /* UNCOMMENT line of code below if you are using onPremise Oracle NoSQL + * Database. Leave the line commented if you are using NoSQL Database + * Cloud Service + handle = await getConnection_onPrem(); */ + await createTable(handle); + let putResult = await handle.put(TABLE_NAME, JSON.parse(add1)); + let putResult1 = await handle.put(TABLE_NAME, JSON.parse(add2)); + let putResult2 = await handle.put(TABLE_NAME, JSON.parse(add3)); + let putResult3 = await handle.put(TABLE_NAME, JSON.parse(add4)); + console.log("Wrote records of examplesAddress schema"); + await fetchRowCnt(handle,stmt1); + await mulRowDel(handle,1234567); + await fetchRowCnt(handle,stmt1); + } catch (error ) { + console.log(error); + } + finally { + if (handle) { + handle.close(); + } + } +} + +/* Create and return an instance of a NoSQLCLient object for cloud service */ +function getConnection_cloud() { + /* replace the placeholders for compartment and region with actual values.*/ + const Region = ``; + return new NoSQLClient({ + region: Region, + compartment: "", + }); +} +/* Create and return an instance of a NoSQLCLient object for onPremises */ +function getConnection_onPrem() { + /* replace the placeholder with the fullname of your host */ + const kvstore_endpoint = `http://:8080`; + return new NoSQLClient({ + serviceType: "KVSTORE", + endpoint: kvstore_endpoint + }); + /* if it is a secure store, comment the return statement above and + * uncomment the lines below and pass the credentials, username and password + return new NoSQLClient({ + "serviceType": "KVSTORE", + "endpoint": "", + "auth": { + "kvstore":{ + "user": "", + "password": "" + } + } + }); */ +} + +//creates a table +async function createTable(handle: NoSQLClient) { + const createDDL = `CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (id INTEGER, + address_line1 STRING, + address_line2 STRING, + pin INTEGER, + PRIMARY KEY(SHARD(pin), id))`; + console.log('Create table: ' + createDDL); + let res = await handle.tableDDL(createDDL, { + complete: true, + tableLimits: { + readUnits: 20, + writeUnits: 20, + storageGB: 1 + } + }); + console.log('Table created: ' + TABLE_NAME); +} +//fetches data from the table +async function fetchRowCnt(handle: NoSQLClient,querystmt: string) { + const opt = {}; + try { + do { + const result = await handle.query(querystmt, opt); + for(let row of result.rows) { + console.log(' %O', row); + } + opt.continuationKey = result.continuationKey; + } while(opt.continuationKey); + } catch(error) { + console.error(' Error: ' + error.message); + } +} + +//deletes multiple rows +async function mulRowDel(handle: NoSQLClient,pinval: string){ + try { + /* Unconditional delete, should succeed.*/ + var result = await handle.deleteRange(TABLE_NAME, { pin: pinval }); + /* Expected output: delete succeeded*/ + console.log('delete ' + result.success ? 'succeeded' : 'failed'); + } catch(error) { + console.error(' Error: ' + error.message); + } +} diff --git a/examples-nosql-node-sdk/sqlexamples/typescript/MultiWrite.ts b/examples-nosql-node-sdk/sqlexamples/typescript/MultiWrite.ts new file mode 100644 index 0000000..0a6c76f --- /dev/null +++ b/examples-nosql-node-sdk/sqlexamples/typescript/MultiWrite.ts @@ -0,0 +1,168 @@ +/* Copyright (c) 2023, 2024 Oracle and/or its affiliates. + * Licensed under the Universal Permissive License v 1.0 as shown at + * https://oss.oracle.com/licenses/upl/ + */ +'use strict'; + +import { NoSQLClient, Region } from 'oracle-nosqldb'; //Uncomment for Cloud +/* import { NoSQLClient, ServiceType } from 'oracle-nosqldb'; */ //Uncomment for On-Premise +interface DesctableInt { + flightNo: String; + flightDate: TIMESTAMP; + fltRouteSrc: String; + fltRouteDest: String; + estimatedArrival: TIMESTAMP; + actions: JSON; +} + +/** + * Call the main function + **/ +domultiwrite(); + +async function domultiwrite() { + let handle; + try { + /* UNCOMMENT line of code below if you are using Oracle NoSQL Database + * Cloud service. Leave the line commented if you are using onPrem database*/ + handle = await getConnection_cloud(); + /* UNCOMMENT line of code below if you are using onPremise Oracle NoSQL + * Database. Leave the line commented if you are using NoSQL Database + * Cloud Service + handle = await getConnection_onPrem(); */ + const table_name = 'ticket'; + const regtbl_DDL = `CREATE TABLE IF NOT EXISTS ${table_name} (ticketNo LONG, + confNo STRING, + primary key(ticketNo))`; + const childtable_name = 'ticket.bagInfo'; + const childtbl_DDL = `CREATE TABLE IF NOT EXISTS ${childtable_name} (id LONG, + tagNum LONG, + routing STRING, + lastActionCode STRING, + lastActionDesc STRING, + lastSeenStation STRING, + lastSeenTimeGmt TIMESTAMP(4), + bagArrivalDate TIMESTAMP(4), + PRIMARY KEY(id))`; + const desctable_name = 'ticket.bagInfo.flightLegs'; + const desctbl_DDL = `CREATE TABLE IF NOT EXISTS ${desctable_name} (flightNo STRING, + flightDate TIMESTAMP(4), + fltRouteSrc STRING, + fltRouteDest STRING, + estimatedArrival TIMESTAMP(4), + actions JSON, + PRIMARY KEY(flightNo))`; + const data1=`{ + "ticketNo":"1762344493810", + "id":"79039899165297", + "flightNo":"BM604", + "flightDate":"2019-02-01T06:00:00Z", + "fltRouteSrc":"MIA", + "fltRouteDest":"LAX", + "estimatedArrival":"2019-02-01T11:00:00Z", + "actions":[ { + "actionAt" : "MIA", + "actionCode" : "ONLOAD to LAX", + "actionTime" : "2019-02-01T06:13:00Z" + }, { + "actionAt" : "MIA", + "actionCode" : "BagTag Scan at MIA", + "actionTime" : "2019-02-01T05:47:00Z" + }, { + "actionAt" : "MIA", + "actionCode" : "Checkin at MIA", + "actionTime" : "2019-02-01T04:38:00Z" + } ] + }` + + await createTable(handle,regtbl_DDL,true,table_name); + await createTable(handle,childtbl_DDL,false,childtable_name); + await createTable(handle,desctbl_DDL,false,desctable_name); + const ops = [ + { + tableName: 'ticket', + put: { + "ticketNo": "1762344493810", + "confNo" : "LE6J4Z" + }, + abortOnFail: true + }, + { + tableName: 'ticket.bagInfo', + put: { + "ticketNo":"1762344493810", + "id":"79039899165297", + "tagNum":"17657806255240", + "routing":"MIA/LAX/MEL", + "lastActionCode":"OFFLOAD", + "lastActionDesc":"OFFLOAD", + "lastSeenStation":"MEL", + "lastSeenTimeGmt":"2019-02-01T16:13:00Z", + "bagArrivalDate":"2019-02-01T16:13:00Z" + }, + abortOnFail: true + } + ]; + const res = await handle.writeMany(ops, null); + console.log("Wrote records in ticket and bagInfo table"); + let putResult = await handle.put(desctable_name, JSON.parse(data1)); + console.log("Wrote records in flightlegs table"); + } catch (error ) { + console.log(error); + } + finally { + if (handle) { + handle.close(); + } + } +} +/* Create and return an instance of a NoSQLCLient object for cloud service */ +function getConnection_cloud() { + /* replace the placeholders for compartment and region with actual values.*/ + const Region = ``; + return new NoSQLClient({ + region: Region, + compartment: "", + }); +} +/* Create and return an instance of a NoSQLCLient object for onPremises */ +function getConnection_onPrem() { + /* replace the placeholder with the fullname of your host */ + const kvstore_endpoint = `http://:8080`; + return new NoSQLClient({ + serviceType: "KVSTORE", + endpoint: kvstore_endpoint + }); + /* if it is a secure store, comment the return statement above and + * uncomment the lines below and pass the credentials, username and password + return new NoSQLClient({ + "serviceType": "KVSTORE", + "endpoint": "", + "auth": { + "kvstore":{ + "user": "", + "password": "" + } + } + }); */ +} + +//creates a table +async function createTable(handle: NoSQLClient, query_stmt: string, reg_table: boolean, table_name: string): Promise { + let res; + if(reg_table==true){ + res = await handle.tableDDL(query_stmt, { + complete: true, + tableLimits: { + readUnits: 20, + writeUnits: 20, + storageGB: 1 + } + }); + } else{ + res = await handle.tableDDL(query_stmt, { + complete: true + }); + } + console.log('Table created: ' + table_name); +} diff --git a/examples-nosql-node-sdk/sqlexamples/typescript/Namespaces.ts b/examples-nosql-node-sdk/sqlexamples/typescript/Namespaces.ts new file mode 100644 index 0000000..1262a4a --- /dev/null +++ b/examples-nosql-node-sdk/sqlexamples/typescript/Namespaces.ts @@ -0,0 +1,64 @@ +/* Copyright (c) 2023, 2024 Oracle and/or its affiliates. + * Licensed under the Universal Permissive License v 1.0 as shown at + * https://oss.oracle.com/licenses/upl/ + */ +'use strict'; +/*import { NoSQLClient, Region } from 'oracle-nosqldb'; */ //Uncomment for Cloud +import { NoSQLClient, ServiceType } from 'oracle-nosqldb'; //Uncomment for On-Premise +const TABLE_NAME = 'stream_acct'; + +/* + * Call the main function + */ +donamespaces(); + +async function donamespaces() { + let handle; + try { + handle = await getConnection_onPrem(); + await createNS(handle); + await dropNS(handle); + } catch (error ) { + console.log(error); + } + finally { + if (handle) { + handle.close(); + } + } +} + +/* Create and return an instance of a NoSQLCLient object for onPremises */ +function getConnection_onPrem() { + /* replace the placeholder with the fullname of your host */ + const kvstore_endpoint = `http://:8080`; + return new NoSQLClient({ + serviceType: "KVSTORE", + endpoint: kvstore_endpoint + }); + /* if it is a secure store, comment the return statement above and + * uncomment the lines below and pass the credentials, username and password + return new NoSQLClient({ + "serviceType": "KVSTORE", + "endpoint": "", + "auth": { + "kvstore":{ + "user": "", + "password": "" + } + } + }); */ +} + +/* create a namespace */ +async function createNS(handle: NoSQLClient) { + const createNS = `CREATE NAMESPACE IF NOT EXISTS ns1`; + let res = await handle.adminDDL(createNS); + console.log('Namespace created: ns1' ); +} +/* drop a namespace */ +async function dropNS(handle: NoSQLClient) { + const dropNS = `DROP NAMESPACE ns1`; + let res = await handle.adminDDL(dropNS); + console.log('Namespace dropped: ns1' ); +} diff --git a/examples-nosql-node-sdk/sqlexamples/typescript/QueryData.ts b/examples-nosql-node-sdk/sqlexamples/typescript/QueryData.ts new file mode 100644 index 0000000..9adbb42 --- /dev/null +++ b/examples-nosql-node-sdk/sqlexamples/typescript/QueryData.ts @@ -0,0 +1,397 @@ +/* Copyright (c) 2023, 2024 Oracle and/or its affiliates. + * Licensed under the Universal Permissive License v 1.0 as shown at + * https://oss.oracle.com/licenses/upl/ + */ +'use strict'; +import { NoSQLClient, Region } from 'oracle-nosqldb'; //Uncomment for Cloud +/* import { NoSQLClient, ServiceType } from 'oracle-nosqldb'; */ //Uncomment for On-Premise + +interface StreamInt { + acct_Id: Integer; + profile_name: String; + account_expiry: TIMESTAMP; + acct_data: JSON; +} +const TABLE_NAME = 'stream_acct'; +const acct1= ` +{ +"acct_Id":1, +"profile_name":"AP", +"account_expiry":"2023-10-18", +"acct_data":{ + "firstName":"Adam", + "lastName":"Phillips", + "country":"Germany", + "contentStreamed":[ + { + "showName":"At the Ranch", + "showId":26, + "showtype":"tvseries", + "genres":[ + "action", + "crime", + "spanish" + ], + "numSeasons":4, + "seriesInfo":[ + { + "seasonNum":1, + "numEpisodes":2, + "episodes":[ + { + "episodeID":20, + "episodeName":"Season 1 episode 1", + "lengthMin":85, + "minWatched":85, + "date":"2022-04-18" + }, + { + "episodeID":30, + "lengthMin":60, + "episodeName":"Season 1 episode 2", + "minWatched":60, + "date":"2022 - 04 - 18 " + } + ] + }, + { + "seasonNum":2, + "numEpisodes":2, + "episodes":[ + { + "episodeID":40, + "episodeName":"Season 2 episode 1", + "lengthMin":50, + "minWatched":50, + "date":"2022-04-25" + }, + { + "episodeID":50, + "episodeName":"Season 2 episode 2", + "lengthMin":45, + "minWatched":30, + "date":"2022-04-27" + } + ] + }, + { + "seasonNum":3, + "numEpisodes":2, + "episodes":[ + { + "episodeID":60, + "episodeName":"Season 3 episode 1", + "lengthMin":50, + "minWatched":50, + "date":"2022-04-25" + }, + { + "episodeID":70, + "episodeName":"Season 3 episode 2", + "lengthMin":45, + "minWatched":30, + "date":"2022 - 04 - 27 " + } + ] + } + ] + }, + { + "showName":"Bienvenu", + "showId":15, + "showtype":"tvseries", + "genres":[ + "comedy", + "french" + ], + "numSeasons":2, + "seriesInfo":[ + { + "seasonNum":1, + "numEpisodes":2, + "episodes":[ + { + "episodeID":20, + "episodeName":"Bonjour", + "lengthMin":45, + "minWatched":45, + "date":"2022-03-07" + }, + { + "episodeID":30, + "episodeName":"Merci", + "lengthMin":42, + "minWatched":42, + "date":"2022-03-08" + } + ] } + ] } + ]} +}` +const acct2= ` +{ +"acct_Id":2, +"profile_name":"Adwi", +"account_expiry":"2023-10-31", +"acct_data":{ + "firstName":"Adelaide", + "lastName":"Willard", + "country":"France", + "contentStreamed":[ + { + "showName":"Bienvenu", + "showId":15, + "showtype":"tvseries", + "genres":[ + "comedy", + "french" + ], + "numSeasons":2, + "seriesInfo":[ + { + "seasonNum":1, + "numEpisodes":2, + "episodes":[ + { + "episodeID":22, + "episodeName":"Season 1 episode 1", + "lengthMin":65, + "minWatched":65, + "date":"2022-04-18" + }, + { + "episodeID":32, + "lengthMin":60, + "episodeName":"Season 1 episode 2", + "minWatched":60, + "date":"2022-04-18" + } + ] + }, + { + "seasonNum":2, + "numEpisodes":3, + "episodes":[ + { + "episodeID":42, + "episodeName":"Season 2 episode 1", + "lengthMin":50, + "minWatched":50, + "date":"2022-04-25" + } + ] + } + ] + } + ]} +} +` +const acct3= ` +{ +"acct_Id":3, +"profile_name":"Dee", +"account_expiry":"2023-11-28", +"acct_data":{ + "firstName":"Dierdre", + "lastName":"Amador", + "country":"USA", + "contentStreamed":[ + { + "showName":"Bienvenu", + "showId":15, + "showtype":"tvseries", + "genres":[ + "comedy", + "french" + ], + "numSeasons":2, + "seriesInfo":[ + { + "seasonNum":1, + "numEpisodes":2, + "episodes":[ + { + "episodeID":23, + "episodeName":"Season 1 episode 1", + "lengthMin":45, + "minWatched":40, + "date":"2022-08-18" + }, + { + "episodeID":33, + "lengthMin":60, + "episodeName":"Season 1 episode 2", + "minWatched":50, + "date":"2022-08-19" + } + ] + }, + { + "seasonNum":2, + "numEpisodes":3, + "episodes":[ + { + "episodeID":43, + "episodeName":"Season 2 episode 1", + "lengthMin":50, + "minWatched":50, + "date":"2022-08-25" + }, + { + "episodeID":53, + "episodeName":"Season 2 episode 2", + "lengthMin":45, + "minWatched":30, + "date":"2022-08-27" + } + ] + } + ] + }, + { + "showName":"Dane", + "showId":16, + "showtype":"tvseries", + "genres":[ + "comedy", + "drama", + "danish" + ], + "numSeasons":2, + "seriesInfo":[ + { + "seasonNum":1, + "numEpisodes":2, + "episodes":[ + { + "episodeID":24, + "episodeName":"Bonjour", + "lengthMin":45, + "minWatched":45, + "date":"2022-06-07" + }, + { + "episodeID":34, + "episodeName":"Merci", + "lengthMin":42, + "minWatched":42, + "date":"2022-06-08" + } + ] + } + ] + } + ]} +} +` +const stmt1 = 'select * from stream_acct'; +const stmt2 = 'select account_expiry, acct.acct_data.lastName, acct.acct_data.contentStreamed[].showName from stream_acct acct where acct_id=1'; + +/* + * Call the main function + */ +doQueryData(); + +async function doQueryData() { + let handle; + try { + /* UNCOMMENT line of code below if you are using Oracle NoSQL Database + * Cloud service. Leave the line commented if you are using onPrem database*/ + handle = await getConnection_cloud(); + /* UNCOMMENT line of code below if you are using onPremise Oracle NoSQL + * Database. Leave the line commented if you are using NoSQL Database + * Cloud Service + handle = await getConnection_onPrem(); */ + await createTable(handle); + let putResult = await handle.put(TABLE_NAME, JSON.parse(acct1)); + let putResult1 = await handle.put(TABLE_NAME, JSON.parse(acct2)); + let putResult2 = await handle.put(TABLE_NAME, JSON.parse(acct3)); + console.log("Wrote records of acct stream schema"); + console.log("Fetch one row using get API"); + await getRow(handle,2); + console.log("Fetching all rows"); + await fetchData(handle,stmt1); + console.log("Fetching partial filtered rows"); + await fetchData(handle,stmt2); + } catch (error ) { + console.log(error); + } + finally { + if (handle) { + handle.close(); + } + } +} + +/* Create and return an instance of a NoSQLCLient object for cloud service */ +function getConnection_cloud() { + /* replace the placeholders for compartment and region with actual values.*/ + const Region = ``; + return new NoSQLClient({ + region: Region, + compartment: "", + }); +} +/* Create and return an instance of a NoSQLCLient object for onPremises */ +function getConnection_onPrem() { + /* replace the placeholder with the fullname of your host */ + const kvstore_endpoint = `http://:8080`; + return new NoSQLClient({ + serviceType: "KVSTORE", + endpoint: kvstore_endpoint + }); + /* if it is a secure store, comment the return statement above and + * uncomment the lines below and pass the credentials, username and password + return new NoSQLClient({ + "serviceType": "KVSTORE", + "endpoint": "", + "auth": { + "kvstore":{ + "user": "", + "password": "" + } + } + }); */ +} +/* creates a table */ +async function createTable(handle: NoSQLClient) { + const createDDL = `CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (acct_Id INTEGER, + profile_name STRING, + account_expiry TIMESTAMP(1), + acct_data JSON, + primary key(acct_Id))`; + console.log('Create table: ' + createDDL); + let res = await handle.tableDDL(createDDL, { + complete: true, + tableLimits: { + readUnits: 20, + writeUnits: 20, + storageGB: 1 + } + }); + console.log('Table created: ' + TABLE_NAME); +} +/* fetches data from the table */ +async function fetchData(handle: NoSQLClient,querystmt: string) { + const opt = {}; + try { + do { + const result = await handle.query(querystmt, opt); + for(let row of result.rows) { + console.log(' %O', row); + } + opt.continuationKey = result.continuationKey; + } while(opt.continuationKey); + } catch(error) { + console.error(' Error: ' + error.message); + } +} +/*fetches single row with get API*/ +async function getRow(handle: NoSQLClient,idVal: Integer) { + try { + const result = await handle.get(TABLE_NAME,{acct_Id: idVal }); + console.log('Got row: %O', result.row); + } catch(error) { + console.error(' Error: ' + error.message); + } +} diff --git a/examples-nosql-node-sdk/sqlexamples/typescript/Regions.ts b/examples-nosql-node-sdk/sqlexamples/typescript/Regions.ts new file mode 100644 index 0000000..2fb07fd --- /dev/null +++ b/examples-nosql-node-sdk/sqlexamples/typescript/Regions.ts @@ -0,0 +1,97 @@ +/* Copyright (c) 2023, 2024 Oracle and/or its affiliates. + * Licensed under the Universal Permissive License v 1.0 as shown at + * https://oss.oracle.com/licenses/upl/ + */ +'use strict'; +import { NoSQLClient, ServiceType } from 'oracle-nosqldb'; //Uncomment for On-Premise +const TABLE_NAME = 'stream_acct'; + +/* + * Call the main function + */ +doregions(); + +/* This function will authenticate with the cloud service, + * create a table, write a record to the table, then read that record back + */ +async function doregions() { + let handle; + try { + handle = await getConnection_onPrem(); + await createRegion(handle); + await crtTabInRegion(handle); + await dropTabInRegion(handle); + await dropRegion(handle); + } catch (error ) { + console.log(error); + } + finally { + if (handle) { + handle.close(); + } + } +} + +/* Create and return an instance of a NoSQLCLient object for onPremises */ +function getConnection_onPrem() { + /* replace the placeholder with the fullname of your host */ + const kvstore_endpoint = `http://:8080`; + return new NoSQLClient({ + serviceType: "KVSTORE", + endpoint: kvstore_endpoint + }); + /* if it is a secure store, comment the return statement above and + * uncomment the lines below and pass the credentials, username and password + return new NoSQLClient({ + "serviceType": "KVSTORE", + "endpoint": "", + "auth": { + "kvstore":{ + "user": "", + "password": "" + } + } + }); */ +} + +/* creates a remote and a local region */ +async function createRegion(handle: NoSQLClient) { + /* Create a remote region */ + const crtRemReg = `CREATE REGION LON`; + let res = await handle.adminDDL(crtRemReg); + console.log('Remote region created: LON' ); + /* Create a local region */ + const crtLocalReg = `SET LOCAL REGION FRA`; + let res1 = await handle.adminDDL(crtLocalReg); + console.log('Local region created: FRA' ); +} +/* creates a table ina given region */ +async function crtTabInRegion(handle: NoSQLClient) { + const createDDL = `CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (acct_Id INTEGER, + profile_name STRING, + account_expiry TIMESTAMP(1), + acct_data JSON, + primary key(acct_Id)) IN REGIONS FRA`; + let res = await handle.tableDDL(createDDL, { + complete: true, + tableLimits: { + readUnits: 20, + writeUnits: 20, + storageGB: 1 + } + }); + console.log('Table created: ' + TABLE_NAME); +} + +/* drop a table from a region */ +async function dropTabInRegion(handle: NoSQLClient) { + const dropDDL = `DROP TABLE ${TABLE_NAME}`; + let res = await handle.tableDDL(dropDDL); + console.log('Table dropped: ' + TABLE_NAME); +} +/* drop a region */ +async function dropRegion(handle: NoSQLClient) { + const dropReg = `DROP REGION LON`; + let res = await handle.adminDDL(dropReg); + console.log('Region dropped: LON' ); +} diff --git a/examples-nosql-node-sdk/sqlexamples/typescript/SQLExpressions.ts b/examples-nosql-node-sdk/sqlexamples/typescript/SQLExpressions.ts new file mode 100644 index 0000000..2a5f432 --- /dev/null +++ b/examples-nosql-node-sdk/sqlexamples/typescript/SQLExpressions.ts @@ -0,0 +1,475 @@ +/* Copyright (c) 2023, 2024 Oracle and/or its affiliates. + * Licensed under the Universal Permissive License v 1.0 as shown at + * https://oss.oracle.com/licenses/upl/ + */ +'use strict'; + +import { NoSQLClient, Region } from 'oracle-nosqldb'; //Uncomment for Cloud +/* import { NoSQLClient, ServiceType } from 'oracle-nosqldb'; */ //Uncomment for On-Premise +const TABLE_NAME = 'BaggageInfo'; +interface BagInt { + ticketNo: Long; + fullName: String; + gender: String; + contactPhone: String; + confNo: String; + bagInfo: JSON; +} + +const paran_expr = `SELECT fullName, bag.bagInfo.tagNum, bag.bagInfo.routing, + bag.bagInfo[].flightLegs[].fltRouteDest FROM BaggageInfo bag + WHERE bag.bagInfo.flightLegs[].fltRouteSrc=any "SFO" AND + (bag.bagInfo[].flightLegs[].fltRouteDest=any "ATH" OR + bag.bagInfo[].flightLegs[].fltRouteDest=any "JTR" )` +const case_expr = `SELECT fullName, + CASE + WHEN NOT exists bag.bagInfo.flightLegs[0] + THEN "you have no bag info" + WHEN NOT exists bag.bagInfo.flightLegs[1] + THEN "you have one hop" + WHEN NOT exists bag.bagInfo.flightLegs[2] + THEN "you have two hops." + ELSE "you have three hops." + END AS NUMBER_HOPS + FROM BaggageInfo bag WHERE ticketNo=1762341772625` +const seq_trn_expr = `SELECT seq_transform(l.bagInfo[], + seq_transform( + $sq1.flightLegs[], + seq_transform( + $sq2.actions[], + { + "at" : $sq3.actionAt, + "action" : $sq3.actionCode, + "flightNo" : $sq2.flightNo, + "tagNum" : $sq1.tagNum + } + ) + ) + ) AS actions FROM baggageInfo l WHERE ticketNo=1762376407826` + +const bag1= ` +{ + "ticketNo":"1762376407826", + "fullName":"Dierdre Amador", + "gender":"M", + "contactPhone":"165-742-5715", + "confNo":"ZG8Z5N", + "bagInfo":[ { + "id" : "7903989918469", + "tagNum" : "17657806240229", + "routing" : "JFK/MAD", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "MAD", + "flightLegs" : [ { + "flightNo" : "BM495", + "flightDate" : "2019-03-07T07:00:00Z", + "fltRouteSrc" : "JFK", + "fltRouteDest" : "MAD", + "estimatedArrival" : "2019-03-07T14:00:00Z", + "actions" : [ { + "actionAt" : "MAD", + "actionCode" : "Offload to Carousel at MAD", + "actionTime" : "2019-03-07T13:54:00Z" + }, { + "actionAt" : "JFK", + "actionCode" : "ONLOAD to MAD", + "actionTime" : "2019-03-07T07:00:00Z" + }, { + "actionAt" : "JFK", + "actionCode" : "BagTag Scan at JFK", + "actionTime" : "2019-03-07T06:53:00Z" + }, { + "actionAt" : "JFK", + "actionCode" : "Checkin at JFK", + "actionTime" : "2019-03-07T05:03:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-03-07T13:51:00Z", + "bagArrivalDate" : "2019-03-07T13:51:00Z" + } ] +}` +const bag2= ` +{ + "ticketNo":"1762344493810", + "fullName":"Adam Phillips", + "gender":"M", + "contactPhone":"893-324-1064", + "confNo":"LE6J4Z", + "bagInfo":[ { + "id" : "79039899165297", + "tagNum" : "17657806255240", + "routing" : "MIA/LAX/MEL", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "MEL", + "flightLegs" : [ { + "flightNo" : "BM604", + "flightDate" : "2019-02-01T06:00:00Z", + "fltRouteSrc" : "MIA", + "fltRouteDest" : "LAX", + "estimatedArrival" : "2019-02-01T11:00:00Z", + "actions" : [ { + "actionAt" : "MIA", + "actionCode" : "ONLOAD to LAX", + "actionTime" : "2019-02-01T06:13:00Z" + }, { + "actionAt" : "MIA", + "actionCode" : "BagTag Scan at MIA", + "actionTime" : "2019-02-01T05:47:00Z" + }, { + "actionAt" : "MIA", + "actionCode" : "Checkin at MIA", + "actionTime" : "2019-02-01T04:38:00Z" + } ] + }, { + "flightNo" : "BM667", + "flightDate" : "2019-02-01T06:13:00Z", + "fltRouteSrc" : "LAX", + "fltRouteDest" : "MEL", + "estimatedArrival" : "2019-02-01T16:15:00Z", + "actions" : [ { + "actionAt" : "MEL", + "actionCode" : "Offload to Carousel at MEL", + "actionTime" : "2019-02-01T16:15:00Z" + }, { + "actionAt" : "LAX", + "actionCode" : "ONLOAD to MEL", + "actionTime" : "2019-02-01T15:35:00Z" + }, { + "actionAt" : "LAX", + "actionCode" : "OFFLOAD from LAX", + "actionTime" : "2019-02-01T15:18:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-02-01T16:13:00Z", + "bagArrivalDate" : "2019-02-01T16:13:00Z" + } ] +}` + +const bag3= ` +{ + "ticketNo":"1762341772625", + "fullName":"Gerard Greene", + "gender":"M", + "contactPhone":"395-837-3772", + "confNo":"MC0E7R", + "bagInfo":[ { + "id" : "79039899152842", + "tagNum" : "1765780626568", + "routing" : "SFO/IST/ATH/JTR", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "JTR", + "flightLegs" : [ { + "flightNo" : "BM318", + "flightDate" : "2019-03-07T04:00:00Z", + "fltRouteSrc" : "SFO", + "fltRouteDest" : "IST", + "estimatedArrival" : "2019-03-07T17:00:00Z", + "actions" : [ { + "actionAt" : "SFO", + "actionCode" : "ONLOAD to IST", + "actionTime" : "2019-03-07T04:08:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "BagTag Scan at SFO", + "actionTime" : "2019-03-07T03:53:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "Checkin at SFO", + "actionTime" : "2019-03-07T02:20:00Z" + } ] + }, { + "flightNo" : "BM696", + "flightDate" : "2019-03-07T05:08:00Z", + "fltRouteSrc" : "IST", + "fltRouteDest" : "ATH", + "estimatedArrival" : "2019-03-08T04:10:00Z", + "actions" : [ { + "actionAt" : "IST", + "actionCode" : "ONLOAD to ATH", + "actionTime" : "2019-03-08T04:55:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "BagTag Scan at IST", + "actionTime" : "2019-03-08T04:34:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "OFFLOAD from IST", + "actionTime" : "2019-03-08T04:47:00Z" + } ] + }, { + "flightNo" : "BM665", + "flightDate" : "2019-03-07T04:08:00Z", + "fltRouteSrc" : "ATH", + "fltRouteDest" : "JTR", + "estimatedArrival" : "2019-03-07T16:10:00Z", + "actions" : [ { + "actionAt" : "JTR", + "actionCode" : "Offload to Carousel at JTR", + "actionTime" : "2019-03-07T16:09:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "ONLOAD to JTR", + "actionTime" : "2019-03-07T15:51:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "OFFLOAD from ATH", + "actionTime" : "2019-03-07T15:43:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-03-07T16:01:00Z", + "bagArrivalDate" : "2019-03-07T16:01:00Z" + } ] +}` + +const bag4= ` +{ + "ticketNo":"1762320369957", + "fullName":"Lorenzo Phil", + "gender":"M", + "contactPhone":"364-610-4444", + "confNo":"QI3V6Q", + "bagInfo":[ { + "id" : "79039899187755", + "tagNum" : "17657806240001", + "routing" : "SFO/IST/ATH/JTR", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "JTR", + "flightLegs" : [ { + "flightNo" : "BM318", + "flightDate" : "2019-03-12T03:00:00Z", + "fltRouteSrc" : "SFO", + "fltRouteDest" : "IST", + "estimatedArrival" : "2019-03-12T16:00:00Z", + "actions" : [ { + "actionAt" : "SFO", + "actionCode" : "ONLOAD to IST", + "actionTime" : "2019-03-12T03:11:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "BagTag Scan at SFO", + "actionTime" : "2019-03-12T02:49:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "Checkin at SFO", + "actionTime" : "2019-03-12T01:50:00Z" + } ] + }, { + "flightNo" : "BM696", + "flightDate" : "2019-03-12T04:11:00Z", + "fltRouteSrc" : "IST", + "fltRouteDest" : "ATH", + "estimatedArrival" : "2019-03-13T03:14:00Z", + "actions" : [ { + "actionAt" : "IST", + "actionCode" : "ONLOAD to ATH", + "actionTime" : "2019-03-13T04:10:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "BagTag Scan at IST", + "actionTime" : "2019-03-13T03:56:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "OFFLOAD from IST", + "actionTime" : "2019-03-13T03:59:00Z" + } ] + }, { + "flightNo" : "BM665", + "flightDate" : "2019-03-12T03:11:00Z", + "fltRouteSrc" : "ATH", + "fltRouteDest" : "JTR", + "estimatedArrival" : "2019-03-12T15:12:00Z", + "actions" : [ { + "actionAt" : "JTR", + "actionCode" : "Offload to Carousel at JTR", + "actionTime" : "2019-03-12T15:06:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "ONLOAD to JTR", + "actionTime" : "2019-03-12T14:16:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "OFFLOAD from ATH", + "actionTime" : "2019-03-12T14:13:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-03-12T15:05:00Z", + "bagArrivalDate" : "2019-03-12T15:05:00Z" + }, + { + "id" : "79039899197755", + "tagNum" : "17657806340001", + "routing" : "SFO/IST/ATH/JTR", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "JTR", + "flightLegs" : [ { + "flightNo" : "BM318", + "flightDate" : "2019-03-12T03:00:00Z", + "fltRouteSrc" : "SFO", + "fltRouteDest" : "IST", + "estimatedArrival" : "2019-03-12T16:40:00Z", + "actions" : [ { + "actionAt" : "SFO", + "actionCode" : "ONLOAD to IST", + "actionTime" : "2019-03-12T03:14:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "BagTag Scan at SFO", + "actionTime" : "2019-03-12T02:50:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "Checkin at SFO", + "actionTime" : "2019-03-12T01:58:00Z" + } ] + }, { + "flightNo" : "BM696", + "flightDate" : "2019-03-12T04:11:00Z", + "fltRouteSrc" : "IST", + "fltRouteDest" : "ATH", + "estimatedArrival" : "2019-03-13T03:18:00Z", + "actions" : [ { + "actionAt" : "IST", + "actionCode" : "ONLOAD to ATH", + "actionTime" : "2019-03-13T04:17:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "BagTag Scan at IST", + "actionTime" : "2019-03-13T03:59:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "OFFLOAD from IST", + "actionTime" : "2019-03-13T03:48:00Z" + } ] + }, { + "flightNo" : "BM665", + "flightDate" : "2019-03-12T03:11:00Z", + "fltRouteSrc" : "ATH", + "fltRouteDest" : "JTR", + "estimatedArrival" : "2019-03-12T15:12:00Z", + "actions" : [ { + "actionAt" : "JTR", + "actionCode" : "Offload to Carousel at JTR", + "actionTime" : "2019-03-12T15:06:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "ONLOAD to JTR", + "actionTime" : "2019-03-12T14:16:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "OFFLOAD from ATH", + "actionTime" : "2019-03-12T14:23:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-03-12T16:05:00Z", + "bagArrivalDate" : "2019-03-12T16:25:00Z" + } ] +}` +/** + * Call the main function + **/ +doSQLOperators(); + +async function doSQLOperators() { + let handle; + try { + /* UNCOMMENT line of code below if you are using Oracle NoSQL Database + * Cloud service. Leave the line commented if you are using onPrem database*/ + handle = await getConnection_cloud(); + /* UNCOMMENT line of code below if you are using onPremise Oracle NoSQL + * Database. Leave the line commented if you are using NoSQL Database + * Cloud Service + handle = await getConnection_onPrem(); */ + await createTable(handle); + let putResult = await handle.put(TABLE_NAME, JSON.parse(bag1)); + let putResult1 = await handle.put(TABLE_NAME, JSON.parse(bag2)); + let putResult2 = await handle.put(TABLE_NAME, JSON.parse(bag3)); + let putResult3 = await handle.put(TABLE_NAME, JSON.parse(bag4)); + console.log("Wrote records of BaggageInfo schema"); + console.log("Using Paranthesized expression"); + await fetchData(handle,paran_expr); + + console.log("Using Case Expression"); + await fetchData(handle,case_expr); + + console.log("Using Sequence Transform Expressions"); + await fetchData(handle,seq_trn_expr); + } catch (error ) { + console.log(error); + } + finally { + if (handle) { + handle.close(); + } + } +} + +/* Create and return an instance of a NoSQLCLient object for cloud service */ +function getConnection_cloud() { + /* replace the placeholders for compartment and region with actual values.*/ + const Region = ``; + return new NoSQLClient({ + region: Region, + compartment: "", + }); +} +/* Create and return an instance of a NoSQLCLient object for onPremises */ +function getConnection_onPrem() { + /* replace the placeholder with the fullname of your host */ + const kvstore_endpoint = `http://:8080`; + return new NoSQLClient({ + serviceType: "KVSTORE", + endpoint: kvstore_endpoint + }); + /* if it is a secure store, comment the return statement above and + * uncomment the lines below and pass the credentials, username and password + return new NoSQLClient({ + "serviceType": "KVSTORE", + "endpoint": "", + "auth": { + "kvstore":{ + "user": "", + "password": "" + } + } + }); */ +} + +//creates a table +async function createTable(handle: NoSQLClient) { + const createDDL = `CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (ticketNo LONG, + fullName STRING, + gender STRING, + contactPhone STRING, + confNo STRING, + bagInfo JSON, + primary key(ticketNo))`; + console.log('Create table: ' + createDDL); + let res = await handle.tableDDL(createDDL, { + complete: true, + tableLimits: { + readUnits: 20, + writeUnits: 20, + storageGB: 1 + } + }); + console.log('Table created: ' + TABLE_NAME); +} +//fetches data from the table +async function fetchData(handle: NoSQLClient,querystmt: string) { + const opt = {}; + try { + do { + const result = await handle.query(querystmt, opt); + for(let row of result.rows) { + console.log(' %O', row); + } + opt.continuationKey = result.continuationKey; + } while(opt.continuationKey); + } catch(error) { + console.error(' Error: ' + error.message); + } +} diff --git a/examples-nosql-node-sdk/sqlexamples/typescript/SQLFunctions.ts b/examples-nosql-node-sdk/sqlexamples/typescript/SQLFunctions.ts new file mode 100644 index 0000000..68d037b --- /dev/null +++ b/examples-nosql-node-sdk/sqlexamples/typescript/SQLFunctions.ts @@ -0,0 +1,465 @@ +/* Copyright (c) 2023, 2024 Oracle and/or its affiliates. + * Licensed under the Universal Permissive License v 1.0 as shown at + * https://oss.oracle.com/licenses/upl/ + */ +'use strict'; + +import { NoSQLClient, Region } from 'oracle-nosqldb'; //Uncomment for Cloud +/* import { NoSQLClient, ServiceType } from 'oracle-nosqldb'; */ //Uncomment for On-Premise +const TABLE_NAME = 'BaggageInfo'; + +interface BagInt { + ticketNo: Long; + fullName: String; + gender: String; + contactPhone: String; + confNo: String; + bagInfo: JSON; +} +const ts_func1 = `SELECT timestamp_add(bag.bagInfo.flightLegs[0].estimatedArrival, "5 minutes") + AS ARRIVAL_TIME FROM BaggageInfo bag WHERE ticketNo=1762341772625` +const ts_func2 = `SELECT $s.ticketno, $bagInfo.bagArrivalDate, $flightLeg.flightDate, + get_duration(timestamp_diff($bagInfo.bagArrivalDate, $flightLeg.flightDate)) AS diff + FROM baggageinfo $s, + $s.bagInfo[] AS $bagInfo, $bagInfo.flightLegs[] AS $flightLeg + WHERE ticketNo=1762344493810` +const string_func1 = `SELECT substring(bag.baginfo.routing,0,3) AS Source FROM baggageInfo bag + WHERE ticketNo=1762376407826` +const string_func2 = `SELECT fullname, length(fullname) AS fullname_length FROM BaggageInfo + WHERE ticketNo=1762320369957` +const string_func3 = `SELECT fullname FROM baggageInfo bag WHERE + EXISTS bag.bagInfo[contains($element.routing,"SFO")]` + +const bag1= ` +{ + "ticketNo":"1762376407826", + "fullName":"Dierdre Amador", + "gender":"M", + "contactPhone":"165-742-5715", + "confNo":"ZG8Z5N", + "bagInfo":[ { + "id" : "7903989918469", + "tagNum" : "17657806240229", + "routing" : "JFK/MAD", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "MAD", + "flightLegs" : [ { + "flightNo" : "BM495", + "flightDate" : "2019-03-07T07:00:00Z", + "fltRouteSrc" : "JFK", + "fltRouteDest" : "MAD", + "estimatedArrival" : "2019-03-07T14:00:00Z", + "actions" : [ { + "actionAt" : "MAD", + "actionCode" : "Offload to Carousel at MAD", + "actionTime" : "2019-03-07T13:54:00Z" + }, { + "actionAt" : "JFK", + "actionCode" : "ONLOAD to MAD", + "actionTime" : "2019-03-07T07:00:00Z" + }, { + "actionAt" : "JFK", + "actionCode" : "BagTag Scan at JFK", + "actionTime" : "2019-03-07T06:53:00Z" + }, { + "actionAt" : "JFK", + "actionCode" : "Checkin at JFK", + "actionTime" : "2019-03-07T05:03:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-03-07T13:51:00Z", + "bagArrivalDate" : "2019-03-07T13:51:00Z" + } ] +}` +const bag2= ` +{ + "ticketNo":"1762344493810", + "fullName":"Adam Phillips", + "gender":"M", + "contactPhone":"893-324-1064", + "confNo":"LE6J4Z", + "bagInfo":[ { + "id" : "79039899165297", + "tagNum" : "17657806255240", + "routing" : "MIA/LAX/MEL", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "MEL", + "flightLegs" : [ { + "flightNo" : "BM604", + "flightDate" : "2019-02-01T06:00:00Z", + "fltRouteSrc" : "MIA", + "fltRouteDest" : "LAX", + "estimatedArrival" : "2019-02-01T11:00:00Z", + "actions" : [ { + "actionAt" : "MIA", + "actionCode" : "ONLOAD to LAX", + "actionTime" : "2019-02-01T06:13:00Z" + }, { + "actionAt" : "MIA", + "actionCode" : "BagTag Scan at MIA", + "actionTime" : "2019-02-01T05:47:00Z" + }, { + "actionAt" : "MIA", + "actionCode" : "Checkin at MIA", + "actionTime" : "2019-02-01T04:38:00Z" + } ] + }, { + "flightNo" : "BM667", + "flightDate" : "2019-02-01T06:13:00Z", + "fltRouteSrc" : "LAX", + "fltRouteDest" : "MEL", + "estimatedArrival" : "2019-02-01T16:15:00Z", + "actions" : [ { + "actionAt" : "MEL", + "actionCode" : "Offload to Carousel at MEL", + "actionTime" : "2019-02-01T16:15:00Z" + }, { + "actionAt" : "LAX", + "actionCode" : "ONLOAD to MEL", + "actionTime" : "2019-02-01T15:35:00Z" + }, { + "actionAt" : "LAX", + "actionCode" : "OFFLOAD from LAX", + "actionTime" : "2019-02-01T15:18:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-02-01T16:13:00Z", + "bagArrivalDate" : "2019-02-01T16:13:00Z" + } ] +}` + +const bag3= ` +{ + "ticketNo":"1762341772625", + "fullName":"Gerard Greene", + "gender":"M", + "contactPhone":"395-837-3772", + "confNo":"MC0E7R", + "bagInfo":[ { + "id" : "79039899152842", + "tagNum" : "1765780626568", + "routing" : "SFO/IST/ATH/JTR", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "JTR", + "flightLegs" : [ { + "flightNo" : "BM318", + "flightDate" : "2019-03-07T04:00:00Z", + "fltRouteSrc" : "SFO", + "fltRouteDest" : "IST", + "estimatedArrival" : "2019-03-07T17:00:00Z", + "actions" : [ { + "actionAt" : "SFO", + "actionCode" : "ONLOAD to IST", + "actionTime" : "2019-03-07T04:08:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "BagTag Scan at SFO", + "actionTime" : "2019-03-07T03:53:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "Checkin at SFO", + "actionTime" : "2019-03-07T02:20:00Z" + } ] + }, { + "flightNo" : "BM696", + "flightDate" : "2019-03-07T05:08:00Z", + "fltRouteSrc" : "IST", + "fltRouteDest" : "ATH", + "estimatedArrival" : "2019-03-08T04:10:00Z", + "actions" : [ { + "actionAt" : "IST", + "actionCode" : "ONLOAD to ATH", + "actionTime" : "2019-03-08T04:55:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "BagTag Scan at IST", + "actionTime" : "2019-03-08T04:34:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "OFFLOAD from IST", + "actionTime" : "2019-03-08T04:47:00Z" + } ] + }, { + "flightNo" : "BM665", + "flightDate" : "2019-03-07T04:08:00Z", + "fltRouteSrc" : "ATH", + "fltRouteDest" : "JTR", + "estimatedArrival" : "2019-03-07T16:10:00Z", + "actions" : [ { + "actionAt" : "JTR", + "actionCode" : "Offload to Carousel at JTR", + "actionTime" : "2019-03-07T16:09:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "ONLOAD to JTR", + "actionTime" : "2019-03-07T15:51:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "OFFLOAD from ATH", + "actionTime" : "2019-03-07T15:43:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-03-07T16:01:00Z", + "bagArrivalDate" : "2019-03-07T16:01:00Z" + } ] +}` + +const bag4= ` +{ + "ticketNo":"1762320369957", + "fullName":"Lorenzo Phil", + "gender":"M", + "contactPhone":"364-610-4444", + "confNo":"QI3V6Q", + "bagInfo":[ { + "id" : "79039899187755", + "tagNum" : "17657806240001", + "routing" : "SFO/IST/ATH/JTR", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "JTR", + "flightLegs" : [ { + "flightNo" : "BM318", + "flightDate" : "2019-03-12T03:00:00Z", + "fltRouteSrc" : "SFO", + "fltRouteDest" : "IST", + "estimatedArrival" : "2019-03-12T16:00:00Z", + "actions" : [ { + "actionAt" : "SFO", + "actionCode" : "ONLOAD to IST", + "actionTime" : "2019-03-12T03:11:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "BagTag Scan at SFO", + "actionTime" : "2019-03-12T02:49:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "Checkin at SFO", + "actionTime" : "2019-03-12T01:50:00Z" + } ] + }, { + "flightNo" : "BM696", + "flightDate" : "2019-03-12T04:11:00Z", + "fltRouteSrc" : "IST", + "fltRouteDest" : "ATH", + "estimatedArrival" : "2019-03-13T03:14:00Z", + "actions" : [ { + "actionAt" : "IST", + "actionCode" : "ONLOAD to ATH", + "actionTime" : "2019-03-13T04:10:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "BagTag Scan at IST", + "actionTime" : "2019-03-13T03:56:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "OFFLOAD from IST", + "actionTime" : "2019-03-13T03:59:00Z" + } ] + }, { + "flightNo" : "BM665", + "flightDate" : "2019-03-12T03:11:00Z", + "fltRouteSrc" : "ATH", + "fltRouteDest" : "JTR", + "estimatedArrival" : "2019-03-12T15:12:00Z", + "actions" : [ { + "actionAt" : "JTR", + "actionCode" : "Offload to Carousel at JTR", + "actionTime" : "2019-03-12T15:06:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "ONLOAD to JTR", + "actionTime" : "2019-03-12T14:16:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "OFFLOAD from ATH", + "actionTime" : "2019-03-12T14:13:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-03-12T15:05:00Z", + "bagArrivalDate" : "2019-03-12T15:05:00Z" + }, + { + "id" : "79039899197755", + "tagNum" : "17657806340001", + "routing" : "SFO/IST/ATH/JTR", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "JTR", + "flightLegs" : [ { + "flightNo" : "BM318", + "flightDate" : "2019-03-12T03:00:00Z", + "fltRouteSrc" : "SFO", + "fltRouteDest" : "IST", + "estimatedArrival" : "2019-03-12T16:40:00Z", + "actions" : [ { + "actionAt" : "SFO", + "actionCode" : "ONLOAD to IST", + "actionTime" : "2019-03-12T03:14:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "BagTag Scan at SFO", + "actionTime" : "2019-03-12T02:50:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "Checkin at SFO", + "actionTime" : "2019-03-12T01:58:00Z" + } ] + }, { + "flightNo" : "BM696", + "flightDate" : "2019-03-12T04:11:00Z", + "fltRouteSrc" : "IST", + "fltRouteDest" : "ATH", + "estimatedArrival" : "2019-03-13T03:18:00Z", + "actions" : [ { + "actionAt" : "IST", + "actionCode" : "ONLOAD to ATH", + "actionTime" : "2019-03-13T04:17:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "BagTag Scan at IST", + "actionTime" : "2019-03-13T03:59:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "OFFLOAD from IST", + "actionTime" : "2019-03-13T03:48:00Z" + } ] + }, { + "flightNo" : "BM665", + "flightDate" : "2019-03-12T03:11:00Z", + "fltRouteSrc" : "ATH", + "fltRouteDest" : "JTR", + "estimatedArrival" : "2019-03-12T15:12:00Z", + "actions" : [ { + "actionAt" : "JTR", + "actionCode" : "Offload to Carousel at JTR", + "actionTime" : "2019-03-12T15:06:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "ONLOAD to JTR", + "actionTime" : "2019-03-12T14:16:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "OFFLOAD from ATH", + "actionTime" : "2019-03-12T14:23:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-03-12T16:05:00Z", + "bagArrivalDate" : "2019-03-12T16:25:00Z" + } ] +}` +/** + * Call the main function + **/ +doSQLOperators(); + +async function doSQLOperators() { + let handle; + try { + /* UNCOMMENT line of code below if you are using Oracle NoSQL Database + * Cloud service. Leave the line commented if you are using onPrem database*/ + handle = await getConnection_cloud(); + /* UNCOMMENT line of code below if you are using onPremise Oracle NoSQL + * Database. Leave the line commented if you are using NoSQL Database + * Cloud Service + handle = await getConnection_onPrem(); */ + await createTable(handle); + let putResult = await handle.put(TABLE_NAME, JSON.parse(bag1)); + let putResult1 = await handle.put(TABLE_NAME, JSON.parse(bag2)); + let putResult2 = await handle.put(TABLE_NAME, JSON.parse(bag3)); + let putResult3 = await handle.put(TABLE_NAME, JSON.parse(bag4)); + console.log("Wrote records of BaggageInfo schema"); + console.log("Using timestamp_add function:"); + await fetchData(handle,ts_func1); + + console.log("Using get_duration and timestamp_diff function:"); + await fetchData(handle,ts_func2); + + console.log("Using substring function:"); + await fetchData(handle,string_func1); + + console.log("Using length function"); + await fetchData(handle,string_func2); + + console.log("Using contains function"); + await fetchData(handle,string_func3); + } catch (error ) { + console.log(error); + } + finally { + if (handle) { + handle.close(); + } + } +} + +/* Create and return an instance of a NoSQLCLient object for cloud service */ +function getConnection_cloud() { + /* replace the placeholders for compartment and region with actual values.*/ + const Region = ``; + return new NoSQLClient({ + region: Region, + compartment: "", + }); +} +/* Create and return an instance of a NoSQLCLient object for onPremises */ +function getConnection_onPrem() { + /* replace the placeholder with the fullname of your host */ + const kvstore_endpoint = `http://:8080`; + return new NoSQLClient({ + serviceType: "KVSTORE", + endpoint: kvstore_endpoint + }); + /* if it is a secure store, comment the return statement above and + * uncomment the lines below and pass the credentials, username and password + return new NoSQLClient({ + "serviceType": "KVSTORE", + "endpoint": "", + "auth": { + "kvstore":{ + "user": "", + "password": "" + } + } + }); */ +} + +//creates a table +async function createTable(handle: NoSQLClient) { + const createDDL = `CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (ticketNo LONG, + fullName STRING, + gender STRING, + contactPhone STRING, + confNo STRING, + bagInfo JSON, + primary key(ticketNo))`; + console.log('Create table: ' + createDDL); + let res = await handle.tableDDL(createDDL, { + complete: true, + tableLimits: { + readUnits: 20, + writeUnits: 20, + storageGB: 1 + } + }); + console.log('Table created: ' + TABLE_NAME); +} + +//fetches data from the table +async function fetchData(handle: NoSQLClient,querystmt: string) { + const opt = {}; + try { + do { + const result = await handle.query(querystmt, opt); + for(let row of result.rows) { + console.log(' %O', row); + } + opt.continuationKey = result.continuationKey; + } while(opt.continuationKey); + } catch(error) { + console.error(' Error: ' + error.message); + } +} diff --git a/examples-nosql-node-sdk/sqlexamples/typescript/SQLOperators.ts b/examples-nosql-node-sdk/sqlexamples/typescript/SQLOperators.ts new file mode 100644 index 0000000..b80f920 --- /dev/null +++ b/examples-nosql-node-sdk/sqlexamples/typescript/SQLOperators.ts @@ -0,0 +1,464 @@ +/* Copyright (c) 2023, 2024 Oracle and/or its affiliates. + * Licensed under the Universal Permissive License v 1.0 as shown at + * https://oss.oracle.com/licenses/upl/ + */ +'use strict'; + +import { NoSQLClient, Region } from 'oracle-nosqldb'; //Uncomment for Cloud +/* import { NoSQLClient, ServiceType } from 'oracle-nosqldb'; */ //Uncomment for On-Premise +const TABLE_NAME = 'BaggageInfo'; +interface BagInt { + ticketNo: Long; + fullName: String; + gender: String; + contactPhone: String; + confNo: String; + bagInfo: JSON; +} + +const seqcomp_stmt = `SELECT bag.bagInfo[].tagNum,bag.bagInfo[].flightLegs[].fltRouteSrc + FROM BaggageInfo bag WHERE bag.bagInfo[].flightLegs[].fltRouteSrc=any "SFO"` +const logope_stmt = `SELECT fullName, bag.bagInfo[].tagNum, bag.bagInfo[].routing, + bag.bagInfo[].flightLegs[].fltRouteSrc + FROM BaggageInfo bag + WHERE NOT bag.bagInfo[].flightLegs[].fltRouteSrc=any "SFO"` +const valcomp_stmt = `SELECT fullname, bag.bagInfo[].routing FROM BaggageInfo bag WHERE gender="M"` +const inope_stmt = `SELECT bagdet.fullName, bagdet.bagInfo[].tagNum + FROM BaggageInfo bagdet WHERE bagdet.fullName IN + ("Lucinda Beckman", "Adam Phillips","Dierdre Amador","Fallon Clements")` +const existsope_stmt = `SELECT fullName, bag.ticketNo FROM BaggageInfo bag WHERE + EXISTS bag.bagInfo[$element.bagArrivalDate >="2019-03-01T00:00:00"]` + +const bag1= ` +{ + "ticketNo":"1762376407826", + "fullName":"Dierdre Amador", + "gender":"M", + "contactPhone":"165-742-5715", + "confNo":"ZG8Z5N", + "bagInfo":[ { + "id" : "7903989918469", + "tagNum" : "17657806240229", + "routing" : "JFK/MAD", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "MAD", + "flightLegs" : [ { + "flightNo" : "BM495", + "flightDate" : "2019-03-07T07:00:00Z", + "fltRouteSrc" : "JFK", + "fltRouteDest" : "MAD", + "estimatedArrival" : "2019-03-07T14:00:00Z", + "actions" : [ { + "actionAt" : "MAD", + "actionCode" : "Offload to Carousel at MAD", + "actionTime" : "2019-03-07T13:54:00Z" + }, { + "actionAt" : "JFK", + "actionCode" : "ONLOAD to MAD", + "actionTime" : "2019-03-07T07:00:00Z" + }, { + "actionAt" : "JFK", + "actionCode" : "BagTag Scan at JFK", + "actionTime" : "2019-03-07T06:53:00Z" + }, { + "actionAt" : "JFK", + "actionCode" : "Checkin at JFK", + "actionTime" : "2019-03-07T05:03:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-03-07T13:51:00Z", + "bagArrivalDate" : "2019-03-07T13:51:00Z" + } ] +}` +const bag2= ` +{ + "ticketNo":"1762344493810", + "fullName":"Adam Phillips", + "gender":"M", + "contactPhone":"893-324-1064", + "confNo":"LE6J4Z", + "bagInfo":[ { + "id" : "79039899165297", + "tagNum" : "17657806255240", + "routing" : "MIA/LAX/MEL", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "MEL", + "flightLegs" : [ { + "flightNo" : "BM604", + "flightDate" : "2019-02-01T06:00:00Z", + "fltRouteSrc" : "MIA", + "fltRouteDest" : "LAX", + "estimatedArrival" : "2019-02-01T11:00:00Z", + "actions" : [ { + "actionAt" : "MIA", + "actionCode" : "ONLOAD to LAX", + "actionTime" : "2019-02-01T06:13:00Z" + }, { + "actionAt" : "MIA", + "actionCode" : "BagTag Scan at MIA", + "actionTime" : "2019-02-01T05:47:00Z" + }, { + "actionAt" : "MIA", + "actionCode" : "Checkin at MIA", + "actionTime" : "2019-02-01T04:38:00Z" + } ] + }, { + "flightNo" : "BM667", + "flightDate" : "2019-02-01T06:13:00Z", + "fltRouteSrc" : "LAX", + "fltRouteDest" : "MEL", + "estimatedArrival" : "2019-02-01T16:15:00Z", + "actions" : [ { + "actionAt" : "MEL", + "actionCode" : "Offload to Carousel at MEL", + "actionTime" : "2019-02-01T16:15:00Z" + }, { + "actionAt" : "LAX", + "actionCode" : "ONLOAD to MEL", + "actionTime" : "2019-02-01T15:35:00Z" + }, { + "actionAt" : "LAX", + "actionCode" : "OFFLOAD from LAX", + "actionTime" : "2019-02-01T15:18:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-02-01T16:13:00Z", + "bagArrivalDate" : "2019-02-01T16:13:00Z" + } ] +}` + +const bag3= ` +{ + "ticketNo":"1762341772625", + "fullName":"Gerard Greene", + "gender":"M", + "contactPhone":"395-837-3772", + "confNo":"MC0E7R", + "bagInfo":[ { + "id" : "79039899152842", + "tagNum" : "1765780626568", + "routing" : "SFO/IST/ATH/JTR", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "JTR", + "flightLegs" : [ { + "flightNo" : "BM318", + "flightDate" : "2019-03-07T04:00:00Z", + "fltRouteSrc" : "SFO", + "fltRouteDest" : "IST", + "estimatedArrival" : "2019-03-07T17:00:00Z", + "actions" : [ { + "actionAt" : "SFO", + "actionCode" : "ONLOAD to IST", + "actionTime" : "2019-03-07T04:08:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "BagTag Scan at SFO", + "actionTime" : "2019-03-07T03:53:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "Checkin at SFO", + "actionTime" : "2019-03-07T02:20:00Z" + } ] + }, { + "flightNo" : "BM696", + "flightDate" : "2019-03-07T05:08:00Z", + "fltRouteSrc" : "IST", + "fltRouteDest" : "ATH", + "estimatedArrival" : "2019-03-08T04:10:00Z", + "actions" : [ { + "actionAt" : "IST", + "actionCode" : "ONLOAD to ATH", + "actionTime" : "2019-03-08T04:55:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "BagTag Scan at IST", + "actionTime" : "2019-03-08T04:34:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "OFFLOAD from IST", + "actionTime" : "2019-03-08T04:47:00Z" + } ] + }, { + "flightNo" : "BM665", + "flightDate" : "2019-03-07T04:08:00Z", + "fltRouteSrc" : "ATH", + "fltRouteDest" : "JTR", + "estimatedArrival" : "2019-03-07T16:10:00Z", + "actions" : [ { + "actionAt" : "JTR", + "actionCode" : "Offload to Carousel at JTR", + "actionTime" : "2019-03-07T16:09:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "ONLOAD to JTR", + "actionTime" : "2019-03-07T15:51:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "OFFLOAD from ATH", + "actionTime" : "2019-03-07T15:43:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-03-07T16:01:00Z", + "bagArrivalDate" : "2019-03-07T16:01:00Z" + } ] +}` + +const bag4= ` +{ + "ticketNo":"1762320369957", + "fullName":"Lorenzo Phil", + "gender":"M", + "contactPhone":"364-610-4444", + "confNo":"QI3V6Q", + "bagInfo":[ { + "id" : "79039899187755", + "tagNum" : "17657806240001", + "routing" : "SFO/IST/ATH/JTR", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "JTR", + "flightLegs" : [ { + "flightNo" : "BM318", + "flightDate" : "2019-03-12T03:00:00Z", + "fltRouteSrc" : "SFO", + "fltRouteDest" : "IST", + "estimatedArrival" : "2019-03-12T16:00:00Z", + "actions" : [ { + "actionAt" : "SFO", + "actionCode" : "ONLOAD to IST", + "actionTime" : "2019-03-12T03:11:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "BagTag Scan at SFO", + "actionTime" : "2019-03-12T02:49:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "Checkin at SFO", + "actionTime" : "2019-03-12T01:50:00Z" + } ] + }, { + "flightNo" : "BM696", + "flightDate" : "2019-03-12T04:11:00Z", + "fltRouteSrc" : "IST", + "fltRouteDest" : "ATH", + "estimatedArrival" : "2019-03-13T03:14:00Z", + "actions" : [ { + "actionAt" : "IST", + "actionCode" : "ONLOAD to ATH", + "actionTime" : "2019-03-13T04:10:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "BagTag Scan at IST", + "actionTime" : "2019-03-13T03:56:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "OFFLOAD from IST", + "actionTime" : "2019-03-13T03:59:00Z" + } ] + }, { + "flightNo" : "BM665", + "flightDate" : "2019-03-12T03:11:00Z", + "fltRouteSrc" : "ATH", + "fltRouteDest" : "JTR", + "estimatedArrival" : "2019-03-12T15:12:00Z", + "actions" : [ { + "actionAt" : "JTR", + "actionCode" : "Offload to Carousel at JTR", + "actionTime" : "2019-03-12T15:06:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "ONLOAD to JTR", + "actionTime" : "2019-03-12T14:16:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "OFFLOAD from ATH", + "actionTime" : "2019-03-12T14:13:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-03-12T15:05:00Z", + "bagArrivalDate" : "2019-03-12T15:05:00Z" + }, + { + "id" : "79039899197755", + "tagNum" : "17657806340001", + "routing" : "SFO/IST/ATH/JTR", + "lastActionCode" : "OFFLOAD", + "lastActionDesc" : "OFFLOAD", + "lastSeenStation" : "JTR", + "flightLegs" : [ { + "flightNo" : "BM318", + "flightDate" : "2019-03-12T03:00:00Z", + "fltRouteSrc" : "SFO", + "fltRouteDest" : "IST", + "estimatedArrival" : "2019-03-12T16:40:00Z", + "actions" : [ { + "actionAt" : "SFO", + "actionCode" : "ONLOAD to IST", + "actionTime" : "2019-03-12T03:14:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "BagTag Scan at SFO", + "actionTime" : "2019-03-12T02:50:00Z" + }, { + "actionAt" : "SFO", + "actionCode" : "Checkin at SFO", + "actionTime" : "2019-03-12T01:58:00Z" + } ] + }, { + "flightNo" : "BM696", + "flightDate" : "2019-03-12T04:11:00Z", + "fltRouteSrc" : "IST", + "fltRouteDest" : "ATH", + "estimatedArrival" : "2019-03-13T03:18:00Z", + "actions" : [ { + "actionAt" : "IST", + "actionCode" : "ONLOAD to ATH", + "actionTime" : "2019-03-13T04:17:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "BagTag Scan at IST", + "actionTime" : "2019-03-13T03:59:00Z" + }, { + "actionAt" : "IST", + "actionCode" : "OFFLOAD from IST", + "actionTime" : "2019-03-13T03:48:00Z" + } ] + }, { + "flightNo" : "BM665", + "flightDate" : "2019-03-12T03:11:00Z", + "fltRouteSrc" : "ATH", + "fltRouteDest" : "JTR", + "estimatedArrival" : "2019-03-12T15:12:00Z", + "actions" : [ { + "actionAt" : "JTR", + "actionCode" : "Offload to Carousel at JTR", + "actionTime" : "2019-03-12T15:06:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "ONLOAD to JTR", + "actionTime" : "2019-03-12T14:16:00Z" + }, { + "actionAt" : "ATH", + "actionCode" : "OFFLOAD from ATH", + "actionTime" : "2019-03-12T14:23:00Z" + } ] + } ], + "lastSeenTimeGmt" : "2019-03-12T16:05:00Z", + "bagArrivalDate" : "2019-03-12T16:25:00Z" + } ] +}` +/** + * Call the main function + **/ +doSQLOperators(); + +async function doSQLOperators() { + let handle; + try { + /* UNCOMMENT line of code below if you are using Oracle NoSQL Database + * Cloud service. Leave the line commented if you are using onPrem database */ + handle = await getConnection_cloud(); + /* UNCOMMENT line of code below if you are using onPremise Oracle NoSQL + * Database. Leave the line commented if you are using NoSQL Database + * Cloud Service + handle = await getConnection_onPrem(); */ + await createTable(handle); + let putResult = await handle.put(TABLE_NAME, JSON.parse(bag1)); + let putResult1 = await handle.put(TABLE_NAME, JSON.parse(bag2)); + let putResult2 = await handle.put(TABLE_NAME, JSON.parse(bag3)); + let putResult3 = await handle.put(TABLE_NAME, JSON.parse(bag4)); + console.log("Wrote records of BaggageInfo schema"); + console.log("Using Sequence Comparison operator"); + await fetchData(handle,seqcomp_stmt); + + console.log("Using Logical operator"); + await fetchData(handle,logope_stmt); + + console.log("Using Value Comparison operator"); + await fetchData(handle,valcomp_stmt); + + console.log("Using IN operator"); + await fetchData(handle,inope_stmt); + + console.log("Using EXISTS operator"); + await fetchData(handle,existsope_stmt); + } catch (error ) { + console.log(error); + } + finally { + if (handle) { + handle.close(); + } + } +} + +/* Create and return an instance of a NoSQLCLient object for cloud service */ +function getConnection_cloud() { + /* replace the placeholders for compartment and region with actual values.*/ + const Region = ``; + return new NoSQLClient({ + region: Region, + compartment: "", + }); +} +/* Create and return an instance of a NoSQLCLient object for onPremises */ +function getConnection_onPrem() { + /* replace the placeholder with the fullname of your host */ + const kvstore_endpoint = `http://:8080`; + return new NoSQLClient({ + serviceType: "KVSTORE", + endpoint: kvstore_endpoint + }); + /* if it is a secure store, comment the return statement above and + * uncomment the lines below and pass the credentials, username and password + return new NoSQLClient({ + "serviceType": "KVSTORE", + "endpoint": "", + "auth": { + "kvstore":{ + "user": "", + "password": "" + } + } + }); */ +} + +//creates a table +async function createTable(handle: NoSQLClient) { + const createDDL = `CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (ticketNo LONG, + fullName STRING, + gender STRING, + contactPhone STRING, + confNo STRING, + bagInfo JSON, + primary key(ticketNo))`; + console.log('Create table: ' + createDDL); + let res = await handle.tableDDL(createDDL, { + complete: true, + tableLimits: { + readUnits: 20, + writeUnits: 20, + storageGB: 1 + } + }); + console.log('Table created: ' + TABLE_NAME); +} + +//fetches data from the table +async function fetchData(handle: NoSQLClient,querystmt: string) { + const opt = {}; + try { + do { + const result = await handle.query(querystmt, opt); + for(let row of result.rows) { + console.log(' %O', row); + } + opt.continuationKey = result.continuationKey; + } while(opt.continuationKey); + } catch(error) { + console.error(' Error: ' + error.message); + } +} diff --git a/examples-nosql-node-sdk/sqlexamples/typescript/TableJoins.ts b/examples-nosql-node-sdk/sqlexamples/typescript/TableJoins.ts new file mode 100644 index 0000000..3ffd207 --- /dev/null +++ b/examples-nosql-node-sdk/sqlexamples/typescript/TableJoins.ts @@ -0,0 +1,194 @@ +/*Copyright (c) 2023, 2024 Oracle and/or its affiliates. + * Licensed under the Universal Permissive License v 1.0 as shown at + * https://oss.oracle.com/licenses/upl/ + */ +'use strict'; + +import { NoSQLClient, Region } from 'oracle-nosqldb'; //Uncomment for Cloud +interface ParentTableInt { + ticketNo: String; + confNo: String; +} + +interface ChildTableInt { + id: Long; + tagNum: Long; + routing: String; + lastActionCode: String; + lastActionDesc: String; + lastSeenStation: String; + lastSeenTimeGmt: TIMESTAMP; + bagArrivalDate: TIMESTAMP; +} + +interface DesctableInt { + flightNo: String; + flightDate: TIMESTAMP; + fltRouteSrc: String; + fltRouteDest: String; + estimatedArrival: TIMESTAMP; + actions: JSON; +} +/** + * Call the main function + **/ +dotablejoins(); + +async function dotablejoins() { + let handle; + try { + /* UNCOMMENT line of code below if you are using Oracle NoSQL Database + * Cloud service. Leave the line commented if you are using onPrem database*/ + handle = await getConnection_cloud(); + /* UNCOMMENT line of code below if you are using onPremise Oracle NoSQL + * Database. Leave the line commented if you are using NoSQL Database + * Cloud Service + handle = await getConnection_onPrem(); */ + const table_name = 'ticket'; + const regtbl_DDL = `CREATE TABLE IF NOT EXISTS ${table_name} (ticketNo LONG, + confNo STRING, + primary key(ticketNo))`; + const childtable_name = 'ticket.bagInfo'; + const childtbl_DDL = `CREATE TABLE IF NOT EXISTS ${childtable_name} (id LONG, + tagNum LONG, + routing STRING, + lastActionCode STRING, + lastActionDesc STRING, + lastSeenStation STRING, + lastSeenTimeGmt TIMESTAMP(4), + bagArrivalDate TIMESTAMP(4), + PRIMARY KEY(id))`; + const desctable_name = 'ticket.bagInfo.flightLegs'; + const desctbl_DDL = `CREATE TABLE IF NOT EXISTS ${desctable_name} (flightNo STRING, + flightDate TIMESTAMP(4), + fltRouteSrc STRING, + fltRouteDest STRING, + estimatedArrival TIMESTAMP(4), + actions JSON, + PRIMARY KEY(flightNo))`; + + const data1=`{ + "ticketNo": "1762344493810", + "confNo" : "LE6J4Z" + }` + const data2=`{ + "ticketNo":"1762344493810", + "id":"79039899165297", + "tagNum":"17657806255240", + "routing":"MIA/LAX/MEL", + "lastActionCode":"OFFLOAD", + "lastActionDesc":"OFFLOAD", + "lastSeenStation":"MEL", + "lastSeenTimeGmt":"2019-02-01T16:13:00Z", + "bagArrivalDate":"2019-02-01T16:13:00Z" + }` + const data3=`{ + "ticketNo":"1762344493810", + "id":"79039899165297", + "flightNo":"BM604", + "flightDate":"2019-02-01T06:00:00Z", + "fltRouteSrc":"MIA", + "fltRouteDest":"LAX", + "estimatedArrival":"2019-02-01T11:00:00Z", + "actions":[ { + "actionAt" : "MIA", + "actionCode" : "ONLOAD to LAX", + "actionTime" : "2019-02-01T06:13:00Z" + }, { + "actionAt" : "MIA", + "actionCode" : "BagTag Scan at MIA", + "actionTime" : "2019-02-01T05:47:00Z" + }, { + "actionAt" : "MIA", + "actionCode" : "Checkin at MIA", + "actionTime" : "2019-02-01T04:38:00Z" + } ] + }` + const stmt_loj = 'SELECT * FROM ticket a LEFT OUTER JOIN ticket.bagInfo.flightLegs b ON a.ticketNo=b.ticketNo'; + const stmt_nt = 'SELECT * FROM NESTED TABLES (ticket a descendants(ticket.bagInfo.flightLegs b))'; + await createTable(handle,regtbl_DDL,true,table_name); + await createTable(handle,childtbl_DDL,false,childtable_name); + await createTable(handle,desctbl_DDL,false,desctable_name); + let putResult = await handle.put(table_name, JSON.parse(data1)); + console.log("Wrote records in ticket table"); + let putResult1 = await handle.put(childtable_name, JSON.parse(data2)); + console.log("Wrote records in bagInfo table"); + let putResult2 = await handle.put(desctable_name, JSON.parse(data3)); + console.log("Wrote records in flightLegs table"); + console.log("Fetching data using Left Outer Joins"); + await fetchData(handle,stmt_loj); + console.log("Fetching data using NESTED TABLES"); + await fetchData(handle,stmt_nt); + } catch (error ) { + console.log(error); + } + finally { + if (handle) { + handle.close(); + } + } +} +/* Create and return an instance of a NoSQLCLient object for cloud service */ +function getConnection_cloud() { + /* replace the placeholders for compartment and region with actual values.*/ + const Region = ``; + return new NoSQLClient({ + region: Region, + compartment: "", + }); +} +/* Create and return an instance of a NoSQLCLient object for onPremises */ +function getConnection_onPrem() { + /* replace the placeholder with the fullname of your host */ + const kvstore_endpoint = `http://:8080`; + return new NoSQLClient({ + serviceType: "KVSTORE", + endpoint: kvstore_endpoint + }); + /* if it is a secure store, comment the return statement above and + * uncomment the lines below and pass the credentials, username and password + return new NoSQLClient({ + "serviceType": "KVSTORE", + "endpoint": "", + "auth": { + "kvstore":{ + "user": "", + "password": "" + } + } + }); */ +} +/*creates a table*/ +async function createTable(handle: NoSQLClient, query_stmt: string, reg_table: boolean, table_name: string): Promise { + let res; + if(reg_table==true){ + res = await handle.tableDDL(query_stmt, { + complete: true, + tableLimits: { + readUnits: 20, + writeUnits: 20, + storageGB: 1 + } + }); + } else{ + res = await handle.tableDDL(query_stmt, { + complete: true + }); + } + console.log('Table created: ' + table_name); +} +/*fetches data from the table*/ +async function fetchData(handle: NoSQLClient,querystmt: string) { + const opt = {}; + try { + do { + const result = await handle.query(querystmt, opt); + for(let row of result.rows) { + console.log(' %O', row); + } + opt.continuationKey = result.continuationKey; + } while(opt.continuationKey); + } catch(error) { + console.error(' Error: ' + error.message); + } +}