Tutorial on how to store custom classes / EJSON types in MongoDB?


At the moment, I am using two sorts of model objects: JavaScript ES6 classes, and Mongo collections.

I would like to unify this by storing my custom data types in the database directly, but this would require some sort of transformation, since the JS type is enriched to some extent, whereas the database types are more normalized (contain less data or aggregate data from several collections).

Is there any tutorial on how to do something like that efficiently? I came acress EJSON custom datatypes, and there is a short mention in the docs that they may even be stored in the database, but I could not find any tutorial or something like that.


Take a look at https://www.eventedmind.com/search?q=ejson and especially https://www.eventedmind.com/feed/meteor-create-a-custom-ejson-type


Thanks a lot, this is exactly what I was looking for.