alfateam / orange-orm

The ultimate ORM for Node and Typescript
https://orange-orm.io
ISC License
694 stars 20 forks source link

How do I connect to a specific schema in a postgres database? #118

Closed lroal closed 1 week ago

lroal commented 1 week ago

Discussed in https://github.com/alfateam/orange-orm/discussions/117

Originally posted by **yayza** November 20, 2024 ```ts import orange from 'orange-orm'; import { env } from '$env/dynamic/private'; const map = orange.map((x) => ({ tag: x.table('tag').map(({ column }) => ({ id: column('id').numeric().primary().notNullExceptInsert(), name: column('name').string(), createdAt: column('createdAt').dateWithTimeZone().default('now()'), updatedAt: column('updatedAt').dateWithTimeZone().default('now()').notNullExceptInsert() })) })); export const db = map.postgres(env.DATABASE_URL + '?search_path=custom'); ``` ``` error: relation "tag" does not exist at Parser.parseErrorMessage (C:\Users\JOE\Desktop\Projects\dl-sveltekit\node_modules\.pnpm\pg-protocol@1.7.0\node_modules\pg-protocol\dist\parser.js:283:98) at Parser.handlePacket (C:\Users\JOE\Desktop\Projects\dl-sveltekit\node_modules\.pnpm\pg-protocol@1.7.0\node_modules\pg-protocol\dist\parser.js:122:29) at Parser.parse (C:\Users\JOE\Desktop\Projects\dl-sveltekit\node_modules\.pnpm\pg-protocol@1.7.0\node_modules\pg-protocol\dist\parser.js:35:38) at Socket. (C:\Users\JOE\Desktop\Projects\dl-sveltekit\node_modules\.pnpm\pg-protocol@1.7.0\node_modules\pg-protocol\dist\index.js:11:42) at Socket.emit (node:events:519:28) at Socket.emit (node:domain:551:15) at addChunk (node:internal/streams/readable:559:12) at readableAddChunkPushByteMode (node:internal/streams/readable:510:3) at Readable.push (node:internal/streams/readable:390:5) at TCP.onStreamRead (node:internal/stream_base_commons:191:23) { length: 103, severity: 'ERROR', code: '42P01', detail: undefined, hint: undefined, position: '129', internalPosition: undefined, internalQuery: undefined, where: undefined, schema: undefined, table: undefined, column: undefined, dataType: undefined, constraint: undefined, file: 'parse_relation.c', line: '1449', routine: 'parserOpenTable' } ``` If I create the table in `public` schema it works. Thanks!