Sporran은 Flutter 및 웹 애플리케이션에 PouchDB와 유사한 기능을 제공하는 Dart 패키지로, 로컬 NoSQL 데이터베이스 작업을 가능하게 합니다. 효율적인 로컬 스토리지에는 lawndart를 활용하고, CouchDB와의 원활한 통합을 위해 Wilt를 사용합니다. 오프라인 우선 애플리케이션을 위한 설계로, 로컬과 원격 데이터베이스 간 동기화를 지원하여 장치 간 데이터 지속성과 동기화가 필요한 앱에 적합합니다. 가벼운 아키텍처 덕분에 웹 플랫폼에서도 빠른 성능을 보장합니다.
사용 사례
오프라인 우선 모바일 및 웹 앱
CouchDB와의 데이터 동기화
웹 애플리케이션에서의 로컬 데이터 저장
프로그레시브 웹 앱(PWAs)
실시간 협업 애플리케이션
API 응답 캐싱
주요 기능
PouchDB에서 영감을 받은 API
CouchDB 내장 지원
로컬 스토리지에 lawndart 사용
웹에서 가볍고 빠름
자동 충돌 해결
로컬 및 원격 데이터베이스 간의 동기화 기능
적합한 대상
Flutter를 사용하는 웹 개발자
오프라인 데이터 지속성 필요 앱
백엔드로 CouchDB를 사용하는 팀
간단한 NoSQL 저장소를 찾는 개발자
실시간 동기화가 필요한 프로젝트
빠른 데이터 기반 기능 프로토타이핑
고려 사항
웹 플랫폼에 한정
CouchDB와 같은 외부 서비스에 의존합니다
PouchDB 개념에 대한 학습 곡선
대규모 서버 측 데이터베이스에는 적합하지 않습니다
동기화 충돌을 신중하게 처리해야 합니다
더 작은 데이터 세트에 적합
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
Sporran - a PouchDB alike database client for Dart
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.