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 🙏

© 2025 – Pkg Stats / Ryan Hefner

wosql

v0.2.0

Published

without any sql but work like databases

Downloads

8

Readme

WOSQL

WOSQL: 0.2.0WOSQLWOSQL0.2.00.2.0

介绍(Introduction)

WOSQL意为:without any sql but work like databases或者可以称之为喔!sql

前端无需关心数据库操作等问题,专心使用核心:WOTable类或WODoc进行数据的增删改查操作,并且数据永久存在于你的电脑上,除非手动清除,当你想要在任意其他位置,甚至是新的文件,新的项目中也能使用某个项目设置好的数据

请记住一句话:WOSQL不是数据库,而是基于浏览器本地存储的模拟数据库框架,它虽然可以帮助我们在前端实现数据库的效果,但最核心是帮助真实的数据库工作的辅助者

image-20230227204400560

注意点

我们支持的数据量为<5MB

关系型:支持存储string|number, 不支持直接存储图片,音频,等数据(通过base64转码后存储)

非关系型:支持存储任何可序列化的数据

小型练手项目可使用它模拟数据库操作,中大型项目可使用它辅助真实数据库工作

版本更新说明(update introduction)

| 版本(version) | 0.2.0 | | --------------------- | ------------ | | 版本说明(version tag) | 测试版(test) | | 更新时间(update date) | 20230227 | | 技术(technology) | TS |

历史更新点(update points):

  1. 支持无框架使用,即无任何如react,vue...框架的简单项目使用 (0.1.0)
  2. 支持JS简易使用,无需指定类型,直接导出WOTable类直接使用(0.1.0)
  3. 支持第二种无框架使用方式,拜托资源服务器限制(0.1.1)
  4. 整体架构升级(0.2.0)
  5. 增加WODoc模拟非关系型数据库类(0.2.0)
  6. 优化工程文件层级(0.2.0)
  7. 项目核心改变(0.2.0)

安装(install)

npm 安装(npm install)

npm i wosql

无框架安装

//0.2.0前
index.js直接导入使用module方式
index_easy.js直接导入使用src方式加载
//0.2.0开始
index_doc|table_版本号.js直接导入使用module方式
index_doc|table_easy_版本号.js直接导入使用src方式加载

image-20230218194138207

找到index.js进行复制

image-20230218194246306

放置到文件夹中

image-20230218194336308

无框架安装2

与无框架第一种不同的是,这种方式采用<script src="./index_easy.js"></script>方式进行导入,无需使用import语句,无需VSCode插件LiveServer

注意这里我们需要使用的是:index_easy.js!

使用(use)

框架

<script lang="ts" setup>
import { WOTable, WODoc } from 'wosql'
</script>

无框架方式1

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script type="module">
      import { WOTable } from './index_table_0.2.0.js'
      import { WODoc } from './index_doc_0.2.0.js'
    </script>
  </body>
</html>

无框架方式2

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="./index_table_easy_0.2.0.js"></script>
    <script src="./index_doc_easy_0.2.0.js"></script>
    <title>Document</title>
  </head>
  <body>
    <script>
    </script>
  </body>
</html>

QuickStart

框架

use WOTable

<script lang="ts" setup>
import { WOTable } from 'wosql'

 /**
 * 设置表的存储字段列 如下:
 * -------------
 * |id|username|
 * |--|-------|
 * -------------
 */
let l: Array<tools.Column> = [
  {
    name: 'id',
    type: 'number'
  },
  {
    name: 'username',
    type: 'string'
  }
]

let l2: Array<tools.Column> = [
  {
    name: 'id2',
    type: 'number'
  },
  {
    name: 'username2',
    type: 'string'
  }
]
//设置表的行数据
let n = {
  id: 1,
  username: 'lsi'
}
let n1 = {
  id: 2,
  username: 'zhangsan'
}
let n2 = {
  id: 100,
  username: 'z0000n'
}
//创建并初始化表
let table = new WOTable('test', l)
let table2 = new WOTable('ceshi', l2)
//表添加数据
table.enhanceAdd(n)
table.enhanceAdd(n1)
/**
 * 表如下:
 * -------------
 * |id|username|
 * |1|lsi|
 * |2|zhangsan|
 * -------------
 */
table2.enhanceAdd(n2)
//获取单列数据集
console.log(table.enhanceGetColumn('id'))
//获取多列数据集
console.log(table.enhanceGetColumns(['id', 'username']))
//修改某一行数据
table.enhanceChange(0,{id: 100,username:'wangwu'})
//获取当前表的数据,Map-->Object方便使用
console.log(table.enhanceGetData())
//获取索引值为1的行的所有数据
console.log(table.enhanceGetRow(1))
//删除第1行数据,传入参数为索引值
table.enhanceDelete(0)
//清空表中的数据
table.enhanceClear()
//获取表,表名称为:test
console.log(WOTable.enhanceGet('test'))
//获取所有的表
console.log(WOTable.selectAllTables())
//删除数据库中的所有表
WOTable.enhanceDestory()   
//删除test表    
WOTable.destoryTable('test')
</script>

use WODoc

<script lang="ts" setup>
import {  WODoc } from 'wosql'
let doc = new WODoc('testDoc')
let d = [
  {
    id: 1,
    name: 'zhangsan'
  },
  {
    sex: '男',
    pwd: 'sssssss'
  }
]

let d2 = 'wosql-test-doc'

if (WOTool.canJson(d)) {
  //将文档数据添加入WODoc(顺序添加)
  doc.enhanceAdd(d, '1')
  doc.enhanceAdd(d2, '2')
  //将文档数据添加入WODoc(指定索引位置)
  doc.enhanceAddByIndex(0, d2, '3')
}
console.log(doc)
//获取id为1的文档
console.log(doc.enhanceGet('1'))
//获取索引为1的文档
console.log(doc.enhanceGetByIndex(1))
//修改id为1的文档
console.log(doc.enhanceChange('1', 56))
//修改索引为0的文档
console.log(doc.enhanceChangeByIndex(0, 'nihao'))
//删除id为1的文档
console.log(doc.enhanceDelete('1'))
//删除索引为1的文档
console.log(doc.enhanceDeleteByIndex(1))
//获取存储当前文档的容器
console.log(doc.getDocContainer())
</script>

无框架方式1(VSCode-Live Server)

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <title>Document</title>
  </head>
  <body>
    <script type="module">
      import { WOTable } from './index_table_0.2.0.js'
      import { WODoc } from './index_doc_0.2.0.js'
      let l = [
        {
          name: 'id',
          type: 'number'
        },
        {
          name: 'username',
          type: 'string'
        }
      ]
      let n = {
        id: 1,
        username: 'lsi'
      }
      let table = new WOTable('test', l)
      table.enhanceAdd(n)
      console.log(table)
      console.log(WOTable.enhanceGet('test'))
    </script>
  </body>
</html>

无框架方式2(script-src)

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="./index_table_easy_0.2.0.js"></script>
    <script src="./index_doc_easy_0.2.0.js"></script>
    <title>Document</title>
  </head>
  <body>
    <script>
      import { WOTable } from './index.js'
      let l = [
        {
          name: 'id',
          type: 'number'
        },
        {
          name: 'username',
          type: 'string'
        }
      ]
      let n = {
        id: 1,
        username: 'lsi'
      }
      let table = new WOTable('test', l)
      table.enhanceAdd(n)
      console.log(table)
      console.log(WOTable.enhanceGet('test'))
    </script>
  </body>
</html>