]> git.jsancho.org Git - mojodb.git/blobdiff - collection.py
Introducing ObjectId
[mojodb.git] / collection.py
index 3c93b8b3192f909f1d31b01100fa5072e8fb7e01..b8d51a071af117291ff26a1e9e4f3eb406b3d55e 100644 (file)
@@ -19,9 +19,8 @@
 #
 ##############################################################################
 
-import msgpack
 from cursor import Cursor
-import uuid
+from objectid import ObjectId
 
 class Collection(object):
     def __init__(self, database, table_name):
@@ -64,7 +63,7 @@ class Collection(object):
         else:
             docs = doc_or_docs
         for doc in docs:
-            doc_id = uuid.uuid4().hex
+            doc_id = str(ObjectId())
             if not '_id' in doc:
                 doc['_id'] = doc_id
             self._insert_document(doc_id, doc)
@@ -86,7 +85,7 @@ class Collection(object):
         values = {
             'id': doc_id,
             'name': field_name,
-            'value': msgpack.dumps(field_value),
+            'value': self.database.connection.serializer.dumps(field_value),
             }
         if type(field_value) in (int, float):
             values['number'] = field_value