Skip to content

pymongo pluging allowing storing/retriving serialized objects to/from mongodb collection

Notifications You must be signed in to change notification settings

Webinterpret/featmongo

 
 

Repository files navigation

Featmongo

This is a wrapper allowing the usage of serialization (https://github.com/pragmaticcoders/serialization) with pymongo.

Usage

from bson.objectid import ObjectId
import serialization
from featmongo import serializer, document
from pymongo import MongoClient


@serialization.register
class TestDoc(document.Document):

    type_name = "test-doc"

    document.field('foo', None)


client = MongoClient('mongodb://localhost:27017')
db = client['test']
# This configures the client to use the serialization layer.
db.add_son_manipulator(serializer.Transform())

print db.tests.insert([TestDoc(foo='bar')])
#> [ObjectId('5416df0728fcb236317dff7d')]
print db.tests.find_one({'foo': 'bar'})
#> <TestDoc {'_id': ObjectId('5416df0728fcb236317dff7d'), 'foo': u'bar'}>

Changes

Version 0.3.3

  • Fix serialization of bson.int64.Int64 class (compatibility issue with pymongo 3.x).

Version 0.3.1

  • Adapt to serialization version 1.2.0.

Version 0.3.0

  • Python 3 support. Drop support from feat. Use serialization instead.

Version 0.2.0

  • Add support for handling different versions of documents loaded from mongo.

About

pymongo pluging allowing storing/retriving serialized objects to/from mongodb collection

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%