note about using pickle
This commit is contained in:
parent
50ce01d820
commit
f6237d63d9
@ -122,6 +122,8 @@ assert db.test.find_one()["custom"].x() == 5
|
||||
# We can take this one step further by encoding to binary, using a user defined
|
||||
# subtype. This allows us to identify what to decode without resorting to tricks
|
||||
# like the "_type" field used above.
|
||||
# NOTE: you could just pickle the instance and save that. What we do here is a
|
||||
# little more lightweight...
|
||||
def to_binary(custom):
|
||||
return Binary(str(custom.x()), 128)
|
||||
def from_binary(binary):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user