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

ican-db

v1.0.0

Published

ican-db

Downloads

1

Readme

ican-db

前因: 有些app数据不是很大,但是数据逻辑却很复杂,读写频率高,如用sqlite手机有时会发烫,改成这种方式后效率有了明显提升。数据的扁平化处理对一个项目来说,好处很多,抛砖引玉,大家可以尝试。

安装方法

第一步

main.js 中引用

import Vue from 'vue'
import App from './App'
//此处添加引用
import DB from './uni_modules/ican-db/js_sdk/index.js'
Vue.prototype.db = DB;
//引用结束

在启动引导页中执行初始化

//初始化数据
let init = require('@/uni_modules/ican-db/test/init.js');
let initprc = init(); //这里初始化引导页时用
console.log(initprc);//根据初始化的不同执行不同的业务逻辑
//初始化数据结束

注意: init.js 需要根据自己的业务逻辑改写,struct.json为数据结构,coins_eth.json为数据内容,这些都需要改成自己的。这三个文件所在的目录也可以换成自己的。

API

chkAutoId 创建表

@tname String 表名

this.db('tableName').chkAutoId()

createTable 设置自增长

@struct Object 表结构

@tname String 表名

this.db().createTable(struct, tname)

copyTable 复制表

@tname String 目标表名

@cname String 源表名

this.db().copyTable(tname, cname)

getTable 获取表结构

this.db('tableName').getTable()

hasTable 判断表是否存在

@tname String 表名

let has = this.db('tableName').hasTable()

select 获取数据列表

let list = this.db('tableName')
			   .where({field : 'data'})
			   .select()

delete 删除数据

this.db('tableName')
	.where({field : 'data'})
	.delete()

save 添加更新数据 add or replace

@fn String 表结构

@tname String 表名

@ifinsert Boolean 是否插入新数据

this.db('tableName')
	.save(fn, tname, ifinsert);

update 更新数据

@savedata Object 数据[{}]

this.db('tableName')
	.where({})
	.update(data)

cols 获取某一列

@field String

let data = this.db('tableName')
		      .where({})
			  .cols(field)

cols 获取某一行

let data = this.db('tableName')
		      .where({})
			  .find()

value 获取某一值

@field String

let val = this.db('tableName')
		      .where({})
			  .value(field)

count 获取总数

let num = this.db('tableName')
		      .where({})
			  .count()

sum 获取总和

@field String

let num = this.db('tableName')
		      .where({})
			  .sum(field)

max 获取最大数

@field String

let num = this.db('tableName')
		      .where({})
			  .max(field)

min 获取最小数

@field String

let num = this.db('tableName')
		      .where({})
			  .min(field)

inserto 查询后插入数据

@tname String

this.db('tableName')
	.where({})
	.select()
	.inserto(tname)

insert 插入数据

@data Object [{}]

this.db('tableName')
	.insert(daga)

join 联表查询

@tname String

@data Object {}

let data = this.db('tableName')
	           .join(tname, {field : "data"})
			   .select();

order 排序

@field String @type String

this.db('tableName')
	.where({where})
	.order(field, 'desc')
	.select()

page 分页

@page Number @pagesize Number

this.db('tableName')
	.where({where})
	.select()
	.page(page,pagesize)