pip_services3_data 1.0.6

  • Readme
  • Changelog
  • Example
  • Installing
  • 81

Pip.Services Logo #

Data persistence for Dart #

This framework is a part of the Pip.Services project. This package contains various design patterns for working with data and provides implementation of reusable data processing and persistence components:

Quick Links:

Acknowledgements #

The Dart version of Pip.Services is created and maintained by:

  • Sergey Seroukhov
  • Levichev Dmitry

The documentation is written by:

  • Levichev Dmitry

1.0.0 #

  • Initial version, created by Sergey Seroukhov and Dmitry Levichev

1.0.1 #

  • Add support for IClonable objects in methods of IdentifiableMemoryPersistence

1.0.2 #

  • Add suffix Ex for methods getListByFilter and getPageByFilter in IdentifiableMemoryPersistence

1.0.3 #

  • Add getCountByFilterEx in IdentiifibleMemoryPersistence

1.0.4 #

  • Fix return list size in getPageByFilterEx method in IdentifiableMemoryPersistence

1.0.5 #

  • Add suffix Ex for method deleteByFilter in IdentifiableMemoryPersistence

1.0.6 #

  • Fix deleteById method in IdentifiableMemoryPersistence. 22-06-2020, Levichev Dmitry

example/README.md

Examples for Components #

This package contains various design patterns for working with data and provides implementation of reusable data processing and persistence components:

  • MemoryPersistence
  • Example:
     class MyMemoryPersistence extends MemoryPersistence<MyData> {

        Future<MyData> getByName(String correlationId, String name) async {
             var item = _.find(items, (d) => d.name == name);
            return item;
         });

         Future<MyData> set(String correlatonId, MyData item) async {
             items = _.filter(items, (d) => d.name != name);
             items.add(item);
             await save(correlationId);
             return item;
         }
     }

     var persistence = MyMemoryPersistence();

     persistence.set("123", { name: "ABC" })
     var item = await persistence.getByName("123", "ABC")
     print(item);                   // Result: { name: "ABC" }

  • IdentifiableMemoryPersistence
  • Example:
class DummyMemoryPersistence
    extends IdentifiableMemoryPersistence<Dummy, String>
    implements IDummyPersistence {
  DummyMemoryPersistence() : super();

  @override
  Future<DataPage<Dummy>> getPageByFilter(
      String correlationId, filter, PagingParams paging) {
    filter = filter ?? FilterParams();
    var key = filter.getAsNullableString('key');

    return super.getPageByFilterEx(correlationId, (Dummy item) {
      if (key != null && item.key != key) {
        return false;
      }
      return true;
    }, paging, null, null);
  }
}
  • FilePersistence
  • Example:
     class MyJsonFilePersistence extends FilePersistence<MyData> {
        MyJsonFilePersistence([String path]) : super(JsonPersister(path)){
        }

        Future<MyData> getByName(String correlationId, String name) async {
             var item = _.find(items, (d) => d.name == name);
             return item;
        });
        @override
        Future<MyData> set(String correlatonId, MyData item) {
             items = List.from(item.where((d) => d.name != name));
             items.add(item);
             await save(correlationId);
             return item;
        }
    }

  • IdentifiableFilePersistence
  • Example:
     class MyFilePersistence extends IdentifiableFilePersistence<MyData, String> {
         MyFilePersistence([String path]):super(JsonPersister(path)) {
         }

         dynamic _composeFilter(FilterParams filter) {
             filter = filter ?? FilterParams();
             var name = filter.getAsNullableString("name");
             return (item) {
                 if (name != null && item.name != name)
                     return false;
                 return true;
             };
         }

         Future<DataPage<MyData>> getPageByFilter(string correlationId, FilterParams filter, PagingParams paging){
            return super.getPageByFilter(correlationId, _composeFilter(filter), paging, null, null);
         }

     }

     var persistence = MyFilePersistence("./data/data.json");

     await persistence.create("123", { id: "1", name: "ABC" });
     var page = await persistence.getPageByFilter(
             "123",
             FilterParams.fromTuples([
                 "name", "ABC"
             ]),
             null);
             
     print(page.data);          // Result: { id: "1", name: "ABC" }

     var item = await persistence.deleteById("123", "1");

In the help for each class there is a general example of its use. Also one of the quality sources are the source code for the tests.

Use this package as a library

1. Depend on it

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


dependencies:
  pip_services3_data: ^1.0.6

2. Install it

You can install packages from the command line:

with pub:


$ pub get

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

3. Import it

Now in your Dart code, you can use:


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

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

  • Dart: 2.8.4
  • pana: 0.13.14

Analysis suggestions

Package not compatible with SDK flutter

Because it is not compatible with any of the supported runtimes: flutter-native, flutter-web

Package not compatible with runtime flutter-native on android

Because:

  • package:pip_services3_data/pip_services3_data.dart that imports:
  • package:pip_services3_data/src/persistence/persistence.dart that imports:
  • package:pip_services3_data/src/persistence/JsonFilePersister.dart that imports:
  • package:pip_services3_commons/pip_services3_commons.dart that imports:
  • package:pip_services3_commons/src/validate/validate.dart that imports:
  • package:pip_services3_commons/src/validate/ProjectionParamsSchema.dart that imports:
  • package:pip_services3_commons/src/validate/ArraySchema.dart that imports:
  • package:pip_services3_commons/src/reflect/ObjectReader.dart that imports:
  • package:pip_services3_commons/src/reflect/PropertyReflector.dart that imports:
  • dart:mirrors

Package not compatible with runtime flutter-native on ios

Because:

  • package:pip_services3_data/pip_services3_data.dart that imports:
  • package:pip_services3_data/src/persistence/persistence.dart that imports:
  • package:pip_services3_data/src/persistence/JsonFilePersister.dart that imports:
  • package:pip_services3_commons/pip_services3_commons.dart that imports:
  • package:pip_services3_commons/src/validate/validate.dart that imports:
  • package:pip_services3_commons/src/validate/ProjectionParamsSchema.dart that imports:
  • package:pip_services3_commons/src/validate/ArraySchema.dart that imports:
  • package:pip_services3_commons/src/reflect/ObjectReader.dart that imports:
  • package:pip_services3_commons/src/reflect/PropertyReflector.dart that imports:
  • dart:mirrors

Package not compatible with runtime flutter-native on linux

Because:

  • package:pip_services3_data/pip_services3_data.dart that imports:
  • package:pip_services3_data/src/persistence/persistence.dart that imports:
  • package:pip_services3_data/src/persistence/JsonFilePersister.dart that imports:
  • package:pip_services3_commons/pip_services3_commons.dart that imports:
  • package:pip_services3_commons/src/validate/validate.dart that imports:
  • package:pip_services3_commons/src/validate/ProjectionParamsSchema.dart that imports:
  • package:pip_services3_commons/src/validate/ArraySchema.dart that imports:
  • package:pip_services3_commons/src/reflect/ObjectReader.dart that imports:
  • package:pip_services3_commons/src/reflect/PropertyReflector.dart that imports:
  • dart:mirrors

Package not compatible with runtime flutter-native on macos

Because:

  • package:pip_services3_data/pip_services3_data.dart that imports:
  • package:pip_services3_data/src/persistence/persistence.dart that imports:
  • package:pip_services3_data/src/persistence/JsonFilePersister.dart that imports:
  • package:pip_services3_commons/pip_services3_commons.dart that imports:
  • package:pip_services3_commons/src/validate/validate.dart that imports:
  • package:pip_services3_commons/src/validate/ProjectionParamsSchema.dart that imports:
  • package:pip_services3_commons/src/validate/ArraySchema.dart that imports:
  • package:pip_services3_commons/src/reflect/ObjectReader.dart that imports:
  • package:pip_services3_commons/src/reflect/PropertyReflector.dart that imports:
  • dart:mirrors

Package not compatible with runtime flutter-native on windows

Because:

  • package:pip_services3_data/pip_services3_data.dart that imports:
  • package:pip_services3_data/src/persistence/persistence.dart that imports:
  • package:pip_services3_data/src/persistence/JsonFilePersister.dart that imports:
  • package:pip_services3_commons/pip_services3_commons.dart that imports:
  • package:pip_services3_commons/src/validate/validate.dart that imports:
  • package:pip_services3_commons/src/validate/ProjectionParamsSchema.dart that imports:
  • package:pip_services3_commons/src/validate/ArraySchema.dart that imports:
  • package:pip_services3_commons/src/reflect/ObjectReader.dart that imports:
  • package:pip_services3_commons/src/reflect/PropertyReflector.dart that imports:
  • dart:mirrors

Package not compatible with runtime flutter-web on web

Because:

  • package:pip_services3_data/pip_services3_data.dart that imports:
  • package:pip_services3_data/src/persistence/persistence.dart that imports:
  • package:pip_services3_data/src/persistence/JsonFilePersister.dart that imports:
  • package:pip_services3_commons/pip_services3_commons.dart that imports:
  • package:pip_services3_commons/src/validate/validate.dart that imports:
  • package:pip_services3_commons/src/validate/ProjectionParamsSchema.dart that imports:
  • package:pip_services3_commons/src/validate/ArraySchema.dart that imports:
  • package:pip_services3_commons/src/reflect/ObjectReader.dart that imports:
  • package:pip_services3_commons/src/reflect/PropertyReflector.dart that imports:
  • dart:mirrors

Package not compatible with runtime js

Because:

  • package:pip_services3_data/pip_services3_data.dart that imports:
  • package:pip_services3_data/src/persistence/persistence.dart that imports:
  • package:pip_services3_data/src/persistence/JsonFilePersister.dart that imports:
  • package:pip_services3_commons/pip_services3_commons.dart that imports:
  • package:pip_services3_commons/src/validate/validate.dart that imports:
  • package:pip_services3_commons/src/validate/ProjectionParamsSchema.dart that imports:
  • package:pip_services3_commons/src/validate/ArraySchema.dart that imports:
  • package:pip_services3_commons/src/reflect/ObjectReader.dart that imports:
  • package:pip_services3_commons/src/reflect/PropertyReflector.dart that imports:
  • dart:mirrors

Package not compatible with runtime native-aot

Because:

  • package:pip_services3_data/pip_services3_data.dart that imports:
  • package:pip_services3_data/src/persistence/persistence.dart that imports:
  • package:pip_services3_data/src/persistence/JsonFilePersister.dart that imports:
  • package:pip_services3_commons/pip_services3_commons.dart that imports:
  • package:pip_services3_commons/src/validate/validate.dart that imports:
  • package:pip_services3_commons/src/validate/ProjectionParamsSchema.dart that imports:
  • package:pip_services3_commons/src/validate/ArraySchema.dart that imports:
  • package:pip_services3_commons/src/reflect/ObjectReader.dart that imports:
  • package:pip_services3_commons/src/reflect/PropertyReflector.dart that imports:
  • dart:mirrors

Health suggestions

Fix lib/src/persistence/IdentifiableMemoryPersistence.dart. (-1 points)

Analysis of lib/src/persistence/IdentifiableMemoryPersistence.dart reported 2 hints:

line 173 col 14: Use contains instead of indexOf

line 426 col 14: Use contains instead of indexOf

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
pip_services3_commons >=1.0.2 <2.0.0 1.0.11
pip_services3_components >=1.0.2 <2.0.0 1.0.6
sprintf ^4.0.0 4.0.2
Transitive dependencies
charcode 1.1.3
collection 1.14.13 1.15.0-nullsafety
convert 2.1.1
crypto 2.1.5
meta 1.2.2 1.3.0-nullsafety
mustache4dart2 0.1.0
path 1.7.0
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.2.0 1.3.0-nullsafety
uuid 2.2.0
yaml 2.2.1
Dev dependencies
test >=1.14.2 <2.0.0