Node.js - sql()

Creates a reference to a SQL database.

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

Parameters

  • Name
    name
    Required
    Required
    Type
    string
    Description

    The unique name of this database within the project.

  • Name
    migrations
    Optional
    Optional
    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 Nov 14, 2024