npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mssql-ts

v1.0.6

Published

Generate Types from your Microsoft SQL Database

Downloads

11

Readme

MSSQL TS

MSSQL TS is a TypeScript generator tool for converting Microsoft SQL Server (MSSQL) database schemas into TypeScript interfaces. This tool is designed to automate the process of creating TypeScript types based on your database structure, making it easier to work with MSSQL databases in TypeScript projects.

Getting Started

To start using MSSQL TS, simply install the package, configure it to connect to your MSSQL database, and run the generator.

Installation

To install MSSQL TS, you need to have Node.js installed on your system. Once Node.js is installed, you can install MSSQL TS using npm:

npm i mssql-ts -D
# Or Yarn
yarn add mssql-ts --dev
# Or pnpm
pnpm add mssql-ts -D

Sample Usage

import { generator } from "mssql-ts";

generator({
    config: {
        client: "mssql",
        connection: {
            host: "localhost",
            user: "username",
            password: "password",
            database: "my_db"
        },
    },
    capitalizeTypes: true,
    path: `${__dirname}/src`,
    customFileName: "MSSQLTypes"
});

Configuration

The generator function accepts a configuration object with the following properties:

  • config: Database configuration object.
  • client: Specifies the database client (must be "mssql").
  • connection: Database connection details including host, user, password, and database.
  • capitalizeTypes: (Optional) A boolean flag to determine if the TypeScript types should be capitalized. Defaults to true.
  • path: The directory path where the generated TypeScript interfaces will be saved.
  • customFileName: Output file name generated by the MSSQL TS TypeScript generator tool when converting Microsoft SQL Server (MSSQL) database schemas into TypeScript interfaces, the file name can vary based on your configuration or implementation within the tool.

For more detailed configuration settings and options, see the Knex.js documentation.

Scripts

To generate the TypeScript interfaces from your MSSQL database schema, you can use the following script command in your project's package.json file:

"scripts": {
    "mssql-ts-generate": "<ts-node || tsx> main.ts"
}

Replace <ts-node || tsx> with ts-node if you are using standard TypeScript files, or tsx if you are using TypeScript with React JSX syntax. Ensure that main.ts is correctly pointing to your script file that contains the generator function call.

Key Features

  • Automated Schema Conversion: Automatically generates TypeScript interfaces from MSSQL database schemas, ensuring that your TypeScript code remains synchronized with your database structure.
  • Customizable Output: Offers options to capitalize type definitions and specify output directories, allowing for a tailored development experience.
  • Seamless Integration: Designed to integrate smoothly into existing TypeScript projects, making it an ideal choice for developers working with MSSQL databases.
  • Enhanced Development Efficiency: Reduces the manual workload of writing TypeScript interfaces for database tables, speeding up the development process and minimizing human error.

Ideal Use Case

MSSQL TS is perfect for developers and teams working on TypeScript applications that interact with MSSQL databases. Whether you're building enterprise-level applications, working on a personal project, or anywhere in between, this tool can significantly streamline your development process.