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

sqlizze

v1.1.2

Published

sqlite3 ORM for Node.JS/Electron

Downloads

3

Readme

sqlizze

sqlite3 ORM for Node.JS/Electron

Installation

$ npm install sqlizze

Usage

const sqlite3 = require('sqlite3').verbose()
const Sqlizze = require('sqlizze')
const sqlize = new Sqlize('./test.db', sqlite3)

Init

  • define model
let user = sqlize.define({
    name: {
      type: Sqlizze.STRING,
      field: 'name',
      allownull: false,
      defaultValue: 'yanglong',
      comment: 'name'
    },
    my_age: {
      type: Sqlizze.INTEGER,
      field: 'age',
      comment: 'age'
    },

  },{
    tableName: 'dt_user'
  })
  • model's method(return Promise)
//create
user.create({
  name: 'longor',
  my_age: 28
})
//findAll
user.findAll({
  where: {
    my_age: 28
  }
})
//findAndCountAll
user.findAndCountAll({
  where: {
    my_age: 28
  }
})
//findOne
user.findOne({
  where: {
    my_age: 28
  }
})
//update
user.update({
  name: 'yanglong'
},{
  where: {
    my_age: 28
  }
})
//count
user.count({
  where: {
    my_age: 28
  }
})
//sum
user.sum('age',{
  where: {
    my_age: 28
  }
})
//delete
user.delete({
  where: {
    my_age: 28
  }
})
  • Conditional
where: {
    ['$or']: [
      {name_ni: 2},
      {my_age: 2}
    ],
    my_age:{
      ['$or']: [11, 22], // 11 OR 12
      ['$gt']: 6, // > 6
      ['$gte']: 6, // >= 6
      ['$lt']: 6, // < 6
      ['$lte']: 6, // <= 6
      ['$ne']: 6, // != 6
      ['$between']: [6, 10], // BETWEEN 6 AND 10
      ['$notBetween']: [6, 10], // NOT BETWEEN 6 AND 10
      ['$in']: [1, 2], // IN [1, 2]
      ['$notin']: [1, 2], // NOT IN [1, 2]
      ['$like']: '123', // LIKE '%123%'
      ['$notLike']: '123' // NOT LIKE '%123%'
    },
    name_ni: 13
  }

  //eg: 
  let OP = Sqlizze.OP
  await user.fillAll({
    where: {
      my_age: {
        [OP.$gt]: 6 // age > 6
      },
      [OP.$or]: [
        {name: '111'},
        {name: '222'} // name = '111' or name = '222'
      ]
    }
  })
  // WHERE (age > 6) AND (name = '111' or name = '222')
  • Order by
  //orderBy: ['id', 'asc'], // default desc
  orderBy: [['name_ni', 'asc'], ['my_age', 'desc']] // default desc

  //eg: 
  await user.fillAll({
    where: {
      my_age: 28
    },
    orderBy: [['name_ni', 'asc'], ['my_age', 'desc']]
  })
  • Limit Offset
  limit: 1, //default 1000
  offset: 0 //default 0

  //eg:
  await user.fillAll({
    where: {
      my_age: 28
    },
    limit: 20, 
    offset: 20
  })