File tree Expand file tree Collapse file tree
javascript/postgres-js/src/alternatives/websocket Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88 "lint:fix" : " eslint . --fix"
99 },
1010 "dependencies" : {
11- "@aws-sdk/client-sts" : " ^3.1001 .0" ,
12- "@aws-sdk/types" : " ^3.973.5 " ,
11+ "@aws-sdk/client-sts" : " ^3.1021 .0" ,
12+ "@aws-sdk/types" : " ^3.973.7 " ,
1313 "@aws/aurora-dsql-postgresjs-connector" : " ^0.2.1" ,
1414 "buffer" : " ^6.0.3" ,
1515 "net-browserify" : " ^0.2.4" ,
1616 "performance-now" : " ^2.1.0" ,
1717 "postgres" : " ^3.4.7" ,
1818 "process" : " ^0.11.10" ,
1919 "react" : " ^19.2.4" ,
20- "react-dom" : " ^19.2.4 " ,
20+ "react-dom" : " ^19.2.5 " ,
2121 "setimmediate" : " ^1.0.5" ,
2222 "timers-browserify" : " ^2.0.12"
2323 },
Original file line number Diff line number Diff line change 1010use Aws \AuroraDsql \PdoPgsql \AuroraDsql ;
1111use Aws \AuroraDsql \PdoPgsql \DsqlConfig ;
1212
13+ // Works with both admin and non-admin users:
14+ // - Admin users operate in the default "public" schema
15+ // - Non-admin users operate in a custom "myschema" schema
1316function main (): void
1417{
1518 $ clusterEndpoint = getenv ('CLUSTER_ENDPOINT ' ) ?: throw new RuntimeException (
1619 'CLUSTER_ENDPOINT environment variable is required '
1720 );
21+ $ clusterUser = getenv ('CLUSTER_USER ' ) ?: 'admin ' ;
22+
23+ // Determine schema based on user type
24+ $ schema = $ clusterUser === 'admin ' ? 'public ' : 'myschema ' ;
1825
1926 $ config = new DsqlConfig (
2027 host: $ clusterEndpoint ,
28+ user: $ clusterUser ,
2129 occMaxRetries: 3 ,
2230 );
2331 $ pdo = AuroraDsql::connect ($ config );
2432
33+ // Set search_path for the appropriate schema
34+ $ pdo ->exec ("SET search_path = ' {$ schema }' " );
35+
2536 // Simple read
2637 $ stmt = $ pdo ->query ('SELECT 1 AS result ' );
2738 $ row = $ stmt ->fetch (PDO ::FETCH_ASSOC );
You can’t perform that action at this time.
0 commit comments