搜索插件、代码仓与 APP 分类

插件详情v8.0.1

sporran

Dart 的 PouchDB 类似物。使用 lawndart 进行本地存储,使用 Wilt 访问 CouchDB。

Web
近 30 天下载
66
喜欢数
30
Pub 分数
160

安装插件

flutter pub add sporran

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Sporran 是一个 Dart 包,为 Flutter 和 Web 应用程序带来类似 PouchDB 的功能,支持本地 NoSQL 数据库操作。它利用 lawndart 实现高效的本地存储,并通过 Wilt 与 CouchDB 实现无缝集成。专为离线优先的应用程序设计,Sporran 支持本地和远程数据库之间的同步,非常适合需要跨设备数据持久化和同步的应用。其轻量级架构确保了在 Web 平台上的快速性能。

适合场景

  • 离线优先的移动和Web应用
  • 与CouchDB的数据同步
  • Web应用程序中的本地数据存储
  • 渐进式网络应用(PWAs)
  • 实时协作应用
  • API 响应缓存

主要特点

  • 受 PouchDB 启发的 API
  • 对 CouchDB 的内置支持
  • 使用 lawndart 进行本地存储
  • 轻量且快速的网页体验
  • 自动冲突解决
  • 本地数据库与远程数据库之间的同步功能

适合对象

  • 使用 Flutter 的 Web 开发人员
  • 需要离线数据持久化的应用
  • 使用 CouchDB 作为后端的团队
  • 寻求简单 NoSQL 存储的开发者
  • 需要实时同步的项目
  • 快速原型数据驱动功能

使用建议

  • 仅限网页平台
  • 依赖外部服务,如 CouchDB
  • PouchDB 概念的学习曲线
  • 不适合大规模服务器端数据库
  • 需要仔细处理同步冲突
  • 最适合较小的数据集

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Sporran - a PouchDB alike database client for Dart

Build Status

Introduction

Sporran is a PouchDB alike implementation for Dart.

It uses Lawndart(browser local storage client) and Wilt(browser CouchDB client) to allow browser based CouchDB users to transition between online and offline modes and carry on working normally.

When the browser is online Sporran acts just like Wilt, i.e is a CouchDB client, but all database transactions are reflected into local storage. If the browser goes offline Sporran switches to using local storage only, when the browser comes back online the local database is synced up with CouchDB, all transparent to the user.

The CouchDB change notification interface is also used to keep Sporran in sync with any 3rd party changes to your CouchDB database.

Philosophy of operation

Sporran is designed to be used as a CouchDB client with a similar interface to PouchDb and the fact that like PouchDb it allows offline as well as online usage.

There are differences however, the main one being that the CouchDB database is deemed to be the master in all cases of conflict, in that when syncing if Couch has a different document revision to the local one held then it is deemed to be the master and its document wins. This means any local updates that have been made while offline will be lost. This however will only occur if you are not the only user of your database, if you are a single user and no one else can change your database then this situation will not occur as your local revisions will always match CouchDB.

When online all document and attachment updates are comitted to local storage as NOT_UPDATED, then CouchDb is updated, if successful the document is now marked as UPDATED in local storage and its revision and any new/deleted attachments are updated. If the update fails the document is left in local storage, the document will only be removed from local storage if CouchDB replies with a conflicting revision in which case the document will be updated from the CouchDB document and its revision updated as necessary.

Whilst online CouchDD responds to all read and delete requests, local storage being updated as required.

When the user goes offline all document update/creation requests are performed in local storage with the update being marked a NOT_UPDATED. Reads are from local storage and deletes operate on local storage with the delete itself being written to a pending delete queue for processing by CouchDB when we transition to online again. Note that whilst offline any document/attachment creations do not create a revision, likewise updated documents retain the same revision they had last time they were online. Sporran does not create CouchDB revisions.

When the user comes back online the sync() method is invoked(automatically or by manual call), this as you probably suspect re-syncs local storage and CouchDB. Pending deletes are addressed first, followed by documents and attachments marked as NOT_UPDATED. This procedure updates revision numbers and creates any new documents/ attachments as needed, also deleted attachments are addressed. The sync method operates in conjunction with the CouchDB change notification interface which must be enabled for a full sync to be performed. The sync operation runs in the background, the user can just carry on working, they need not wait for the sync oeration to complete, in fact, syncing is performed transparently all the time the user is online albeit in a more lightweight manner.

所属分类

依赖

依赖清单 4 项

  • indexed_db^1.0.1
  • json_object_lite^4.0.1
  • web^1.1.1
  • wilt^7.1.1

源码仓库

使用此插件的项目

暂无相关数据。