zoukankan      html  css  js  c++  java
  • dexie.js,封装了indexedDB本地数据库的插件。更方便使用indexedDB

    indexedDB:用于本地存储大量数据,高达250M,离线功能的数据存储。

    script引入使用

    https://unpkg.com/dexie@latest/dist/dexie.js

    创建数据库与增删改查

    const db = new Dexie("db");
    //++id表示自增的字段
    db.version(1).stores({
        friends: '++id,name,age',
    });
    
    //新增1条数据
    function add(obj) {
        db.friends.add(obj)
    }
    
    //修改1条数据 要带上主键 如id
    function update(obj) {
        db.friends.put(obj)
    }
    
    //删除数据
    function del(key) {
        db.friends.delete(key)
    }
    
    //查询数据
    async function get(key) {
        return db.friends.get(key)
    }
    
    async function init() {
        console.log(await get(3))
    }
    init()
    博客园作者:herry菌,原文链接:

    朋友,看到这里,关注作者的公众号吧,不漏掉更新哦

  • 相关阅读:
    sed命令
    python常用库
    python标准库
    从 Python 打包到 CLI 工具
    pip
    python包自我理解
    docker常用命令
    chattr命令
    xmss
    live2d-widget.js
  • 原文地址:https://www.cnblogs.com/wuhairui/p/15522432.html
Copyright © 2011-2022 走看看