Skip to Main Content

MongoByte MongoDB Logo

Welcome to the new MongoDB Feedback Portal!

{Improvement: "Your idea"}
We’ve upgraded our system to better capture and act on your feedback.
Your feedback is meaningful and helps us build better products.

Status Submitted
Categories Atlas
Created by Guest
Created on Jul 7, 2023

Generate class-based TypeScript object models for Realm from existing schema

The Realm SDKs -> Realm Object Models page (https://realm.mongodb.com/groups//apps//sdks/dataModels) uses the existing schema to generate object models in a variety of languages. However, the TypeScript generator is out-of-date. RealmJs now has first-class TypeScript support, allowing you to declare your models as classes and use @realm/babel-plugin to infer the schema. If your TypeScript objects don't inherit from Realm.Object (which is the case with the models generated currently), the items returned from your queries will be of type `unknown` as well. But if you query using models inherited from Realm.Object everything is strongly typed. Please update the generator to provide class-based TypeScript object models that inherit from Realm.Object as detailed in the documentation here: https://github.com/realm/realm-js/tree/main#typescript-models
  • Attach files