Node.js - sql()

Creates a reference to a SQL database.

import { sql } from '@nitric/sdk'
const db = sql('my-data')

Parameters

  • Name
    name
    Type
    string
    Description

    The unique name of this database within the project.

  • Name
    migrations
    Type
    string
    Description

    Points to the location of migration files, prefixed with file://, or a migration dockerfile, prefixed with dockerfile://.

Examples

Create a reference to a database

import { sql } from '@nitric/sdk'
const db = sql('my-data')

With a migrations directory

import { sql } from '@nitric/sdk'
const db = sql('my-data', {
migrations: 'file://migrations/my-data',
})

With a migrations dockerfile

import { sql } from '@nitric/sdk'
const db = sql('my-data', {
migrations: 'dockerfile://migrations.dockerfile',
})

Connect with Prisma

Connect with Drizzle

See also

Last updated on Oct 11, 2024