jaguar_serializer_mongo 2.1.1

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 65

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 {
  PlayerSerializer();
}

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

  /// Name of the player
  String name;

  Player();
}

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');
  await db.open();

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

    Player player = new Player()
      ..id = id.toHexString()
      ..allianceId = allianceId.toHexString()
      ..name = 'KnightsOT'
      ..email = 'knightsot@example.com'
      ..age = 27
      ..score = 500000
      ..emailConfirmed = true;

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

    Map result = await coll.findOne(where.id(id));
    print(result);

    Player decoded = Player.fromMap(result);
    print(decoded);
  } 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:


dependencies:
  jaguar_serializer_mongo: ^2.1.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages 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';
  
Version Uploaded Documentation Archive
2.1.1 Jul 10, 2018 Go to the documentation of jaguar_serializer_mongo 2.1.1 Download jaguar_serializer_mongo 2.1.1 archive
0.2.0 Nov 3, 2017 Go to the documentation of jaguar_serializer_mongo 0.2.0 Download jaguar_serializer_mongo 0.2.0 archive
0.1.0 Sep 15, 2017 Go to the documentation of jaguar_serializer_mongo 0.1.0 Download jaguar_serializer_mongo 0.1.0 archive
0.0.5 Jun 6, 2017 Go to the documentation of jaguar_serializer_mongo 0.0.5 Download jaguar_serializer_mongo 0.0.5 archive
0.0.4 May 26, 2017 Go to the documentation of jaguar_serializer_mongo 0.0.4 Download jaguar_serializer_mongo 0.0.4 archive
0.0.3 May 4, 2017 Go to the documentation of jaguar_serializer_mongo 0.0.3 Download jaguar_serializer_mongo 0.0.3 archive
0.0.2 Mar 4, 2017 Go to the documentation of jaguar_serializer_mongo 0.0.2 Download jaguar_serializer_mongo 0.0.2 archive
0.0.1 Dec 23, 2016 Go to the documentation of jaguar_serializer_mongo 0.0.1 Download jaguar_serializer_mongo 0.0.1 archive
1.0.0-dev5 Apr 8, 2018 Go to the documentation of jaguar_serializer_mongo 1.0.0-dev5 Download jaguar_serializer_mongo 1.0.0-dev5 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
38
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
65
Learn more about scoring.

We analyzed this package on Dec 5, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.7

Platforms

Detected platforms: Flutter, other

Primary library: package:jaguar_serializer_mongo/jaguar_serializer_mongo.dart with components: io.

Maintenance suggestions

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Maintain an example.

None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use jaguar_serializer_mongo.dart. Packages with multiple examples should use example/readme.md.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.60.0 <3.0.0
jaguar_serializer ^2.1.8 2.2.5
mongo_dart ^0.3.2 0.3.3
Transitive dependencies
async 2.0.8
bson 0.3.2
charcode 1.1.2
collection 1.14.11
convert 2.0.2
crypto 2.0.6
fixnum 0.10.9
logging 0.11.3+2
mongo_dart_query 0.3.2
more 1.12.1
path 1.6.2
pool 1.3.6
stack_trace 1.9.3
typed_data 1.1.6
uuid 1.0.3
Dev dependencies
build_runner ^0.9.0
jaguar_serializer_cli ^2.1.24
test ^1.2.0