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

my_utiles

v1.0.0

Published

>如何使用MySQL

Downloads

4

Readme

如何使用MySQL

进入 bin 下的 db 中

database.js

需要更改信息,修改对应的信息

module.exports={
    port:"",
    dataBase:{
        user:"root", //用户登录信息
        password:"root", //用户登录密码
        database:"books", //表名
        host:'localhost', 
        port:"3306" //端口
    }
}

index.js

列名变化的话,更改指令里的 from 后面list属性,改成自己需要设置的


    //添加数据
    add(obj){
    
    },
    //删除数据
    remove(obj,isFlag="or"){
      
    },
    //更新数据
    update(newObj,values,isFlag="or"){
       
    },
    //筛选 过滤 排序
    select(values="",isFlag="or"){
        
    }

如何使用对应的方法

  • 引入 db 中 index.js
const connect=require("my_utilse/bin/db/index")
  • 使用对应的方法 获取数据库的信息,传的属性必须跟数据库的属性对应
//添加数据
router.post("/login", async (ctx)=>{
    let body=ctx.request.body;  
    let data= await connect.add(body);
    ctx.body=JSON.stringify({
        code:0,
        message:"添加成功"
    })
})

//查询列表
router.get("/data",async (ctx)=>{
    let data= await connect.select();//不传值相等于获取全部的
    ctx.body=data
})

//删除
router.post("/del",async (ctx)=>{
    let {uid}=ctx.request.body;
    let data= await connect.remove({ //传个uid
        uid
    });
})


//更新数据
router.post("/update",async (ctx)=>{
    let {uid,photos}=ctx.request.body;
    let data= await connect.update({ 
        photos     //参数1:需要更改的属性值
    },{
        uid     //参数二:用来匹配对应的 来更改值
    });

})

//倒序正序
router.post('/orderlist', async (ctx, next) => {
    let res = await sql.search({
        order: true,  //倒序正序开关
        colname: 'username' //以什么属性来倒序正序
    })
   
})
//过滤数据
router.post("/select",async (ctx)=>{
    let {classification}=ctx.request.body;
    let data= await connect.select({
        classification  //通过什么属性来过滤
    });
   
})

//排序数据
router.post("/limit",async (ctx)=>{
    let {page,limit}=ctx.request.body;
    let data= await connect.select({
        page:(page*1-1)*limit,  //页数
        limit   //条数
    });
    
})