Giter VIP home page Giter VIP logo

ts-database's Introduction

这是基于 typesciprt 的 indexedDB 的数据库的操作函数

本项目基于 typescript 封装了 indexedDB 基本操作函数,并返回 Promise 操作

实例

import Database from 'ts-database';

// 创建数据库,并创建一个用户表,设置主键为id
const database = new Database({
    name: 'TS_STORE',
    version: 1,
    modules: [{ name: 'users', primary: 'id', columns: [] }]
});

// 造数据
const user = {
    id: 'user0001',
    name: 'XY笔记',
    updatedAt: new Date().getTime()
};

// 创建用户
const createUser = () => {
    console.log('创建用户');
    return database.module('users').then((model) => {
        return model.bulkCreate([user]).then((result) => {
            console.error('创建成功', result);
        });
    });
};

createUser();

接口文档

1、批量保存,存在更新

moduel.bulkCreate();

2、数据更新

moduel.update();

3、批量数据拉取

moduel.findAll();

4、根据主键拉取

moduel.findByPk();

5、 关键词搜索

moduel.findAllLike();

6、 删除

moduel.destory();

7、 表长度

moduel.count();

8、 清表

moduel.clear();

9、 数据库备份

database.backup();

10、 数据库恢复

database.recovery();

ts-database's People

Contributors

xygengcn avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.