jaguar_serializer_mongo 2.2.1

  • Readme
  • Changelog
  • Installing
  • 48

Build Status

jaguar_serializer_mongo #

Mongo serializer helpers for jaguar_serializer

Convert Mongo's ObjectId #

Mongo expects ids to be of type ObjectIds. But in Code, we expect them to be Strings most of the time. [MongoId] custom field processor can be used to automatically encode and decode to ObjectId from String.

@GenSerializer(fields: const {
  'id': const EnDecode(alias: '_id', processor: const MongoId()),
class PlayerSerializer extends Serializer<Player> with _$PlayerSerializer {

/// Player model for the game
class Player {
  /// Id of the player
  String id;

  /// Name of the player
  String name;


Simple example #

import 'package:mongo_dart/mongo_dart.dart';
import '../models/player/player.dart';

main() async {
  Db db = new Db('mongodb://localhost:27017/jaguar_mongo_test');

  try {
    DbCollection coll = db.collection('one');
    ObjectId id = new ObjectId();
    ObjectId allianceId = new ObjectId();

    Player player = new Player() = id.toHexString()
      ..allianceId = allianceId.toHexString() = 'KnightsOT' = ''
      ..age = 27
      ..score = 500000
      ..emailConfirmed = true;

    await coll.insert(player.toMongo());

    Map result = await coll.findOne(;

    Player decoded = Player.fromMap(result);
  } finally {
    await db.drop();
    await db.close();

Changelog #

1.0.0-dev5 #

  • Moved to jaguar_serializer 1.0.0-dev5

0.2.0 #

  • Moved to jaguar_serializer 0.5.x

0.1.0 #

  • Moved to jaguar_serializer 0.4.x

0.0.4 #

  • Added MgoAccess

0.0.3 #

  • Upgraded to jaguar_serializer 0.3.x

0.0.1 #

  • Initial version, created by Stagehand

Use this package as a library

1. Depend on it

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

  jaguar_serializer_mongo: ^2.2.1

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:jaguar_serializer_mongo/jaguar_serializer_mongo.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.9+1

Analysis suggestions

Package not compatible with runtime flutter-web of web

Because of the import of dart:io via the import chain package:jaguar_serializer_mongo/jaguar_serializer_mongo.dart->package:mongo_dart/mongo_dart.dart->dart:io

Package not compatible with runtime web

Because of the import of dart:io via the import chain package:jaguar_serializer_mongo/jaguar_serializer_mongo.dart->package:mongo_dart/mongo_dart.dart->dart:io

Health suggestions

Fix lib/jaguar_serializer_mongo.dart. (-0.50 points)

Analysis of lib/jaguar_serializer_mongo.dart reported 1 hint:

line 21 col 12: Unnecessary new keyword.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (mongo_dart).

Package is getting outdated. (-51.51 points)

The package was last published 79 weeks ago.

The package description is too short. (-12 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example.

None of the files in the package's example/ directory matches known example patterns.

Common filename patterns include main.dart, example.dart, and jaguar_serializer_mongo.dart. Packages with multiple examples should provide example/

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.60.0 <3.0.0
jaguar_serializer ^2.2.6 2.2.12
mongo_dart ^0.3.2 0.3.6 0.4.0
Transitive dependencies
async 2.4.1
bson 0.3.2
charcode 1.1.3
collection 1.14.13
convert 2.1.1
crypto 2.1.5
fixnum 0.10.11
logging 0.11.4
mongo_dart_query 0.3.2 0.4.1
more 1.18.2 2.4.0
path 1.7.0
pool 1.4.0
stack_trace 1.9.5
typed_data 1.2.0
uuid 2.2.0
Dev dependencies
build_runner ^0.10.0
jaguar_serializer_cli ^2.2.1
test ^1.2.0