I heard the upcoming ORM Meteor there .
I am interested in working with it similarly to Polymorphic models for Django .
Firstly, a polymorphic view like django-polymorphic is available with Mongo Documents, and secondly, how can this be done with Meteor Collections?
While you wrote your question, this is probably not feasible, but now it is possible using the transform parameter either when creating new Mongo.Collection , or when executing MyCollection.find or findOne . Given that you want to use polymorphic models, most likely you will use the transform parameter during queries.
transform
new Mongo.Collection
MyCollection.find
findOne
Check out the transform parameter in the following documentation:
http://docs.meteor.com/#/full/mongo_collection
http://docs.meteor.com/#/full/find
http://docs.meteor.com/#/full/findone
Here is an example:
// Your MongoDB collections Resources = new Mongo.Collection('resource'); // Define your model function ProductModel (resource) { /* Model Stuff */ } // As you fetch your data, instantiate the models using the `transform` option var product = Resources.findOne(myFilter, { transform: function (document) { return new ProductModel(document); } });
There are tons of packages that give you the power of models from the start, like Astronomy and Graviton .
Source: https://habr.com/ru/post/1435652/More articles:Can I make jdbc 4.1 source level compatible with jdk 1.6? - javajQuery (document) .ready () doesn't work - javascriptUSB device connectivity in Python - pythonWhat is the advantage of Fluent Validation over default .NET .NET annotations - asp.net-mvcHTML to PDF (using Google Chrome API)? - linuxCheck Unix Message Queue if it is empty or not. - cHaskell Runtime Structure on Multi-Core Processors - parallel-processingCrystal Report Viewer button does not work in Google Chrome and Firefox, but works fine in IE - firefoxRequest for sleeping criteria with group By and aliasToBean - javaDelphi TListView DoubleBuffered does not work if you use styles - delphiAll Articles