I am using Astronomy package and want to implement Custom type. I have read the documentation and looked at examples of array_field.js and object_field.js, but still have hard time building a custom type Set. I want to have a support for Set object. I tried to use the code from array_field, but without much success. Actually it did store something in the document for that field, but it looks broken. I would also like to have Map custom type, i.e. a Map object. If someone can give some guidance on how to implement the following methods:
Hi, for simplicity you can omit the needsCast and the needsPlain methods. It’s just for performance improvements, but to just make it work first you can omit them. In fact we only have to focus on two functions: cast and plain.
I haven’t tested it but it should work. The plain method is called when you are converting a value to a format that will be stored in a database. And the cast method is called when a value is taken in plain format from the database and it needs to be casted to your type.