sporran 4.0.4

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.

Please read the documents under the doc folder for usage information, the API is also under this folder and is available here

Contact #

Queries you can direct to me at steve.hamblett@linux.com or raise an issue here.

4.0.4 #

Linter updates

4.0.3 #

Pub analysis fixes for Dart 2.6.1, general tidy up

4.0.2 #

Formatting for pana

4.0.1 #

Update description for pana

4.0.0 #

Update to dart 2.0, issue 15

3.1.0 #

Update to new Wilt + JsonObjectLite, remove analysis errors

3.0.0 #

Updates ready for Dart 2, remove the completion interface.

2.1.0 #

Updates for issues 7, 5, 6, 8 and 4 Note that issue 4 changes how Sporran is constructed and is thus breaking.

2.0.1 #

Updates for DartV1.5.3, all tests running

2.0.0 #

Issues 1 and 2, Sporran now has a futures based API

1.0.0 #

Initial release

example/sporran.dart

/*
 * Package : Sporran
 * Author : S. Hamblett <steve.hamblett@linux.com>
 * Date   : 17/09/2018
 * Copyright :  S.Hamblett
 */

import 'package:sporran/sporran.dart';
import 'package:json_object_lite/json_object_lite.dart';

// ignore: avoid_relative_lib_imports
import '../test/lib/sporran_test_config.dart';

// ignore_for_file: omit_local_variable_types
// ignore_for_file: unnecessary_final
// ignore_for_file: cascade_invocations
// ignore_for_file: avoid_print

/// An example of sporran initialisation and usage, see the test
/// scenarios for more detailed use cases.
// ignore: avoid_void_async
void main() async {
  // Initialise Sporran
  final SporranInitialiser initialiser = SporranInitialiser();
  initialiser.dbName = databaseName;
  initialiser.hostname = hostName;
  initialiser.manualNotificationControl = true;
  initialiser.port = port;
  initialiser.scheme = scheme;
  initialiser.username = userName;
  initialiser.password = userPassword;
  initialiser.preserveLocal = false;

  // Create the client
  final Sporran sporran = Sporran(initialiser);
  sporran.autoSync = false;
  await sporran.onReady.first;

  // Put a document
  final dynamic onlineDoc = JsonObjectLite<dynamic>();
  const String docIdPutOnline = 'putOnlineg3';
  onlineDoc.name = 'Online';
  await sporran.put(docIdPutOnline, onlineDoc);

  // Get it
  dynamic res = await sporran.get(docIdPutOnline);
  dynamic payload = JsonObjectLite<dynamic>.fromJsonString(res.payload);
  print(payload.payload.name);

  // Get it offline
  sporran.online = false;
  res = sporran.get(docIdPutOnline);
  payload = JsonObjectLite<dynamic>.fromJsonString(res.payload);
  print(payload.payload.name);
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  sporran: ^4.0.4

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:sporran/sporran.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
44
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
72
Learn more about scoring.

We analyzed this package on Feb 14, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <3.0.0
json_object_lite ^2.1.0 2.1.1
wilt >=4.0.0 <=5.0.0 4.0.4
Transitive dependencies
async 2.4.0
charcode 1.1.3
collection 1.14.12
convert 2.1.1
crypto 2.1.4
http 0.12.0+4
http_parser 3.1.3
meta 1.1.8
path 1.6.4
pedantic 1.9.0
source_span 1.6.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
build_runner ^1.7.2
build_test ^0.10.10
build_web_compilers ^2.7.1
test ^1.9.4