You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The most typical use case which we are not yet supporting is serialization/deserialization of fields. So that in JavaScript instances fields are represented by some other value than what is stored in the database. For example, one use case is to store timestamps as Date objects, but use momentjs objects in JavaScript instances.
This is something which is traditionally done by providing custom field types, which know how to serialize/deserialize to and from the database. So we could have a DatetimeField, which would store timestamp as Date object into the database, when it would get it as moment value, and when reading from the database, it would convert Date to moment.
Similarly we can then also implement references (which are just a special case of this), so that users can simply assign some referenced object, and PeerDB makes sure to extract _id and store only that (and any configured fields) into the database. And in the other direction (which is currently already supported as a special case.)
The text was updated successfully, but these errors were encountered:
Probably the best approach here would be that fields modify how document is serialized by EJSON. So that fields provide a decoupled way to augment EJSON serialization.
The most typical use case which we are not yet supporting is serialization/deserialization of fields. So that in JavaScript instances fields are represented by some other value than what is stored in the database. For example, one use case is to store timestamps as
Date
objects, but use momentjs objects in JavaScript instances.This is something which is traditionally done by providing custom field types, which know how to serialize/deserialize to and from the database. So we could have a
DatetimeField
, which would store timestamp asDate
object into the database, when it would get it as moment value, and when reading from the database, it would convertDate
to moment.Similarly we can then also implement references (which are just a special case of this), so that users can simply assign some referenced object, and PeerDB makes sure to extract
_id
and store only that (and any configured fields) into the database. And in the other direction (which is currently already supported as a special case.)The text was updated successfully, but these errors were encountered: