fix(node): pass AWS credentials to db level operations (#908)

Passed the following tests

```ts
const keyId = process.env.AWS_ACCESS_KEY_ID;
const secretKey = process.env.AWS_SECRET_ACCESS_KEY;
const sessionToken = process.env.AWS_SESSION_TOKEN;
const region = process.env.AWS_REGION;

const db = await lancedb.connect({
  uri: "s3://bucket/path",
  awsCredentials: {
    accessKeyId: keyId,
    secretKey: secretKey,
    sessionToken: sessionToken,
  },
  awsRegion: region,
} as lancedb.ConnectionOptions);

  console.log(await db.createTable("test", [{ vector: [1, 2, 3] }]));
  console.log(await db.tableNames());
  console.log(await db.dropTable("test"))
```
This commit is contained in:
Lei Xu
2024-01-31 12:05:01 -08:00
committed by GitHub
parent 8d0ea29f89
commit 5f59e51583
4 changed files with 82 additions and 19 deletions

View File

@@ -163,6 +163,7 @@ export async function connect (
{
uri: '',
awsCredentials: undefined,
awsRegion: defaultAwsRegion,
apiKey: undefined,
region: defaultAwsRegion
},
@@ -174,7 +175,13 @@ export async function connect (
// Remote connection
return new RemoteConnection(opts)
}
const db = await databaseNew(opts.uri)
const db = await databaseNew(
opts.uri,
opts.awsCredentials?.accessKeyId,
opts.awsCredentials?.secretKey,
opts.awsCredentials?.sessionToken,
opts.awsRegion
)
return new LocalConnection(db, opts)
}
@@ -443,7 +450,7 @@ export interface Table<T = number[]> {
*/
indexStats: (indexUuid: string) => Promise<IndexStats>
filter (value: string): Query<T>
filter(value: string): Query<T>
schema: Promise<Schema>
}