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

sqlz

v1.0.2

Published

受到服务端thinkphp 等一些php语言的架构设计编写的sqlite链式操作

Downloads

2

Readme

sqlite 链式操作

受到服务端thinkphp 等一些php语言的架构设计编写的sqlite链式操作

你可以不用编写任何sql语句更直观的管理你的数据库


const { sqlz } = require('../lib/index');
const path = require('path');

console.log(sqlz)


/** ...执行 sqlz 时如果不存在该 db 文件会自动进行新建哦!**/

/** 直接调用 传入完整路径 **/
let Db1 = sqlz(path.join(process.cwd(), '/db/sql.db'),'users');
// console.log(Db1)


/**  使用.db 前缀名 调用相应数据库文件 -> 数据库 文件需要存在node 执行目录 db 文件夹 **/
let Db2 = sqlz('sql','users'); 
// console.log(Db2)


/** 接下来可以使用 实例后的 db 进行链式操作了 **/

// 查询条件 
Db1.where('age > 18').where('gender = 1');

// 输出结果
Db1.select().then(res => {
    console.log(res); 
}).catch(err => {
    console.error(err);
});
Db1.clearQuery();

// 分页查询
Db1.page([2,2]);
Db1.select().then(res => {
    console.log(res);
}).catch(err => {
    console.error(err);
});
Db1.clearQuery();

// 查询数量
Db1.where('age > 18')
Db1.count().then(res => {
    console.log(`查询数量: ${res}`)
}).catch(err => {
    console.error(err);
});
Db1.clearQuery();



// 删除
Db1.where('id = 10')

// 执行删除
Db1.delete().then(res => {
    if(!res){
        console.log('删除失败')
    }else{
        console.log('删除成功')
    }
}).catch(err => {
    console.error(err);
});
Db1.clearQuery();



// 返回sql 语句
Db1.where('age > 18').where('gender = 1').page([2,2]);
Db1.sqls()
// 返回 sql 语句
console.log("sql:",Db1.sqls())
Db1.clearQuery();