Download packages/database/src/context.ts from safetrack/edtech: direct link, hf CLI and curl.
- Browser
- Download file 382 Bytes
-
https://huggingface.co/spaces/safetrack/edtech/resolve/main/packages/database/src/context.ts
- Command line
-
hf download hf://spaces/safetrack/edtech/packages/database/src/context.ts
-
curl -L -o context.ts https://huggingface.co/spaces/safetrack/edtech/resolve/main/packages/database/src/context.ts
382 Bytes
| import { AsyncLocalStorage } from 'async_hooks'; | |
| export const tenantContext = new AsyncLocalStorage<{ organizationId: string }>(); | |
| export const runWithTenant = <T>(organizationId: string, fn: () => T): T => { | |
| return tenantContext.run({ organizationId }, fn); | |
| }; | |
| export const getOrganizationId = (): string | undefined => { | |
| return tenantContext.getStore()?.organizationId; | |
| }; | |