(database, name, source)
| 204 | } |
| 205 | |
| 206 | async function insertSource(database, name, source) { |
| 207 | source = await source; |
| 208 | if (isFileAttachment(source)) return insertFile(database, name, source); |
| 209 | if (isArrowTable(source)) return insertArrowTable(database, name, source); |
| 210 | if (Array.isArray(source)) return insertArray(database, name, source); |
| 211 | if (isArqueroTable(source)) return insertArqueroTable(database, name, source); |
| 212 | if (typeof source === "string") return insertUrl(database, name, source); |
| 213 | if (source && typeof source === "object") { |
| 214 | if ("data" in source) { |
| 215 | // data + options |
| 216 | const {data, ...options} = source; |
| 217 | if (isArrowTable(data)) return insertArrowTable(database, name, data, options); |
| 218 | return insertArray(database, name, data, options); |
| 219 | } |
| 220 | if ("file" in source) { |
| 221 | // file + options |
| 222 | const {file, ...options} = source; |
| 223 | return insertFile(database, name, file, options); |
| 224 | } |
| 225 | } |
| 226 | throw new Error(`invalid source: ${source}`); |
| 227 | } |
| 228 | |
| 229 | async function insertUrl(database, name, url) { |
| 230 | const connection = await database.connect(); |
no test coverage detected