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

active-query-builder

v1.0.5

Published

Simple and flexible way to write your next MySQL queries.

Downloads

23

Readme

active-query-builder

Motto

Simple and flexible way to write your next MySQL queries.

Badges

npm npm GitHubGitHub contributors

PRs Welcome GitHub issues GitHub pull requests node

The problem

Writing queries with mysql is difficult because it doesn't supports ES6 Promise and while working on a personal project I found that same queries are repeated over and over.

This solution

I have come up with a simple and flexible solution for writing repetitive queries using active query builder. This pattern allows information to be retrieved, inserted, and updated in your database with minimal scripting. In some cases only one or two lines of code are necessary to perform a database action.

Getting Started

This package is mainly designed for MySQL. It's written in JavaScript, does not require compiling, and is MIT licensed.

const ActiveQueryBuilder = require('active-query-builder')

// make connection to your database
const conn = new ActiveQueryBuilder({
  host: 'localhost',
  user: 'root',
  password: 'root',
  database: 'sandbox',
})

// query method
conn.query('SELECT * FROM person WHERE email=?', ['[email protected]'])
  .then(({results, fields, query}) => {
    console.log(results) // this is your result
  })

// get method
conn.get('users').then(({results, fields, query}) => {
  console.log(results) // this is your result
})

// get_where method
conn.get_where('users', { 'email': '[email protected]' })
  .then(({ results, fields, query }) => {
    console.log(results) // this is your result
  })

Prerequisites

Things you need to install the package

  1. Node 8.10 or above
  2. MySQL community edition

Installing

A step by step series of examples that tell you how to get a development env running

Say what the step will be

npm install mysql active-query-builder --save

Running the tests

Tests gives us confidence, hence we have written tests for each method. Before creating pull request make sure that you have passed all tests

npm run test

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

Sagar Gavhane - core author

License

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