Skip to content

Commit e7f4845

Browse files
committed
fix: changed the iteration mechanism on the sqlDeveloper function to avoid rate limit errors
1 parent 551b63c commit e7f4845

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

templates/ords-remix-jwt-sample/ords/migrateScripts/autoRESTEnableObjects.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,19 @@ async function autoRESTEnableObjects(schemaName, endpoint, basicAuth) {
9797
const statementsResponse = await postRequest(endpoint, autoRESTenableStatements, basicAuth);
9898
printResponse(statementsResponse);
9999
// Add the SQL Developer role to the objects that where autoREST Enabled.
100-
objectsToRESTEnable.filter((object) => object.isAutoRestAuth).map(async (object) => {
101-
const grantSQLDevStmt = grantSQLDeveloperRole(
100+
const sqlDevObjects = objectsToRESTEnable.filter((object) => object.isAutoRestAuth)
101+
.map((object) => grantSQLDeveloperRole(
102102
schemaName,
103103
object.objectName,
104104
object.objectAlias,
105-
);
106-
const statementResponse = await postRequest(endpoint, grantSQLDevStmt, basicAuth);
105+
));
106+
// Run the statements sequentially to avoid rate limiting errors from the DB
107+
await sqlDevObjects.reduce(async (previousPromise, dev) => {
108+
await previousPromise;
109+
const statementResponse = await postRequest(endpoint, dev, basicAuth);
107110
printResponse(statementResponse);
108-
});
111+
return Promise.resolve();
112+
}, Promise.resolve());
109113
}
110114

111115
export default autoRESTEnableObjects;

0 commit comments

Comments
 (0)