Example #1
0
 def update(self, table, key, properties, upsert = False, replace = False):
     if table not in ['metadata', 'tokenmaps']:
         properties = db.flatten(properties, token_map = self.get_token_map(table, 'encode'))
     if replace:
         update = properties
     else:
         properties.pop('_id', None)
         update = {"$set" : properties}
     self.get_collection(table).update({'_id' : key}, update, upsert = upsert)
Example #2
0
 def test_db_flatten_unflatten(self):
     document = {"_id": "keyname1", "nested": {"item": 1}}
     assert db.unflatten(db.flatten(document)) == document
Example #3
0
 def test_db_flatten(self):
     document = {"_id": "keyname1", "nested": {"item": 1}}
     assert db.flatten(document) == {"_id": "keyname1", "nested|item": 1}
     document = {"_id": "keyname1", "notnested": "a"}
     assert db.flatten(document) == document
Example #4
0
 def test_db_flatten_unflatten(self):
     document = {'_id': 'keyname1', 'nested': {'item': 1}}
     assert db.unflatten(db.flatten(document)) == document
Example #5
0
 def test_db_flatten(self):
     document = {'_id': 'keyname1', 'nested': {'item': 1}}
     assert db.flatten(document) == {'_id': 'keyname1', 'nested|item': 1}
     document = {'_id': 'keyname1', 'notnested': 'a'}
     assert db.flatten(document) == document