You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, I want to say thanks because I am looking for a library that allows me to write migrations in .js file, and this seems to be the only one available and actively maintained. In fact one of the example from Readme illustrated my use case (pulling data from external sources, something that's not possible by writing .sql).
However, I am concern about large query. What if my data source has hundreds or even thousands of rows? While I can do something like
importaxiosfrom"axios";constlargeNumberOfRows=5000;module.exports.generateSql=async()=>{letquery='';for(leti=0;i<largeNumberOfRows;i++){constresponse=awaitaxios({method: "get",url: `https://api.example.org/person/${i}`,});query+=`INSERT INTO person (name, age) VALUES ('${response.data.name}', ${response.data.age});`}returnquery;};
I am worried about the string being too big and causing OOM, so I would like to be able to execute query in each loop instead of concatenating the string. Generator / Async generator seems to be a good api for such use case.
importaxiosfrom"axios";constlargeNumberOfRows=5000;module.exports.generateSql=asyncfunction*(){for(leti=0;i<largeNumberOfRows;i++){constresponse=awaitaxios({method: "get",url: `https://api.example.org/person/${i}`,});yield`INSERT INTO person (name, age) VALUES ('${response.data.name}', ${response.data.age});`}};
What do you think?
The text was updated successfully, but these errors were encountered:
First of all, I want to say thanks because I am looking for a library that allows me to write migrations in .js file, and this seems to be the only one available and actively maintained. In fact one of the example from Readme illustrated my use case (pulling data from external sources, something that's not possible by writing .sql).
However, I am concern about large query. What if my data source has hundreds or even thousands of rows? While I can do something like
I am worried about the string being too big and causing OOM, so I would like to be able to execute query in each loop instead of concatenating the string. Generator / Async generator seems to be a good api for such use case.
What do you think?
The text was updated successfully, but these errors were encountered: