-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #134 from skyflowapi/SK-1370-readme-changelog-samp…
…les-for-continue-on-error-in-batch-insert SK-1370 README, CHANGELOG and Samples
- Loading branch information
Showing
4 changed files
with
145 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,6 @@ | |
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"skyflow-node": "^1.11.0" | ||
"skyflow-node": "^1.13.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
Copyright (c) 2024 Skyflow, Inc. | ||
*/ | ||
import { | ||
Skyflow, | ||
generateBearerToken, | ||
isExpired, | ||
setLogLevel, | ||
LogLevel, | ||
} from "skyflow-node"; | ||
|
||
setLogLevel(LogLevel.DEBUG); | ||
let bearerToken = ""; | ||
const filePath = "<YOUR_CREDENTIALS_FILE_PATH>"; | ||
|
||
const skyflow = Skyflow.init({ | ||
vaultID: "<VAULT_ID>", | ||
vaultURL: "<VAULT_URL>", | ||
getBearerToken: () => { | ||
return new Promise((resolve, reject) => { | ||
if (!isExpired(bearerToken)) { | ||
resolve(bearerToken); | ||
} else { | ||
generateBearerToken(filePath) | ||
.then((response) => { | ||
bearerToken = response.accessToken; | ||
resolve(bearerToken); | ||
}) | ||
.catch((error) => { | ||
reject(error); | ||
}); | ||
} | ||
}); | ||
}, | ||
}); | ||
|
||
const result = skyflow.insert( | ||
{ | ||
records: [ | ||
{ | ||
fields: { | ||
expiry_date: "12/2026", | ||
card_number: "411111111111111", | ||
namee: "john doe", | ||
}, | ||
table: "cards", | ||
}, | ||
{ | ||
fields: { | ||
expiry_date: "12/2027", | ||
card_number: "411111111111111", | ||
name: "jane doe", | ||
}, | ||
table: "cards", | ||
}, | ||
], | ||
}, | ||
{ | ||
tokens: true, | ||
continueOnError: true, | ||
} | ||
); | ||
|
||
result | ||
.then((response) => { | ||
console.log("insert result:"); | ||
console.log(JSON.stringify(response)); | ||
}) | ||
.catch((error) => { | ||
console.log("insert error:"); | ||
console.log(JSON.stringify(error)); | ||
}); |