uni-helper / localForage-adapter

适用于 uni-app 的 localForage 适配器
https://www.npmjs.com/package/@uni-helper/localforage-adapter
MIT License
3 stars 0 forks source link
localforage sqlite sqlite-android sqlite-ios uniapp unistorage

@uni-helper/localforage-adapter

NPM version

安装

# pnpm
pnpm install @uni-helper/localforage-adapter
# npm
npm install @uni-helper/localforage-adapter --save
# yarn
yarn add @uni-helper/localforage-adapter

使用

import { uniStorageDriver, sqliteDriver } from "@uni-helper/localforage-adapter"
import localforage from "localforage"

localforage.defineDriver(uniStorageDriver); // 全端支持,但是还是建议在H5端使用lf自带的IndexedDB
localforage.defineDriver(sqliteDriver); // 仅支持APP端,并需要基座包支持SQLite模块
// 可以使用 #ifdef 等UniAPP特有条件编译注释符
localforage.setDriver([ //会按顺序依次尝试,直到找到可用的驱动
  sqliteDriver._driver // 或者"sqliteDriver"
  uniStorageDriver._driver // 或者"uniStorageDriver"
]);

License

MIT License © 2023-PRESENT Uni-Helper