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

@ayushninja/sql-orm

v1.0.2

Published

An ORM where you can use native query

Downloads

9

Readme

@ayushninja/sql-orm @ayushninja/sql-orm is a lightweight Node.js library that simplifies database connections and querying for MySQL, PostgreSQL, and Microsoft SQL Server (MSSQL) databases. It provides a common interface for connecting to and interacting with different database systems.

Features

  • Supports MySQL, PostgreSQL, and MSSQL databases.
  • Provides a unified API for connecting to and querying databases.
  • Easy parameterized query execution with support for prepared statements.
  • Automatically handles database-specific connection setup.

Installation

To install @ayushninja/sql-orm, you can use npm or yarn:

npm install @ayushninja/sql-orm
# or
yarn add @ayushninja/sql-orm

Usage

Initializing a Connection You can initialize a connection to your database using the createConnection function. Specify the database type, hostname, username, password, and other connection details. Here's an example of how to create a connection:

import { createConnection } from '@ayushninja/sql-orm';

const connectionOptions = {
  type: 'mysql', // 'mysql', 'postgres', or 'mssql'
  database: 'mydb',
  hostname: 'localhost',
  username: 'user',
  password: 'password',
  // Add port if necessary (optional)
  // port: 5432,
};

try {
  await createConnection(connectionOptions);
  console.log('Connected to the database');
  // Now you can execute queries
} catch (error) {
  console.error('Connection error:', error);
}

Executing Queries

You can execute queries using the executeQuery function after establishing a connection. Pass your SQL query and an array of parameters (if necessary) to the function. It will automatically use the appropriate database connection. Here's an example:

import { executeQuery } from '@ayushninja/sql-orm';

const query = 'SELECT * FROM mytable WHERE column = ?';
const params = ['someValue'];

try {
  const result = await executeQuery(query, params);
  console.log('Query result:', result);
} catch (error) {
  console.error('Query error:', error);
}

Supported Databases

MySQL: Requires the mysql2 package. PostgreSQL: Requires the pg package. MSSQL: Requires the tedious package. Make sure to install the necessary database-specific packages according to your use case.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contribution

Feel free to contribute to this project by opening issues or creating pull requests on GitHub at https://github.com/ayushshukla7777/ayush-orm.

Contact

For any questions or feedback, you can reach out to Ayush at [email protected].