Populating Manager with schemas/definitions

Is there a way to create a ModelManager using schema and definition Ids that have not been deployed, but are known?

Scenario - I have several schemas/definitions that I know the IDs for. I want to add them to a manager so I can create a modelJSON file that the app can then use. Not sure how to create that modelJSON (using manager.toJSON()) without using createSchema/createDefinition.

Have tried creating a model using:

let model = new DataModel({ceramic: appClient, aliases})

(which works) - and then adding that to a manager I’ve created using:


but that fails with a “cannot convert undefined or null to object”. As per screenshot, looks to be a valid model so not sure where I’m going wrong.

The DataModel class is for runtime use, based on aliases created by the ModelManager, so you can’t use a DataModel in the ModelManager, it has to be a ManagedModel (cf ModelManager class - Ceramic Developers).
This method is used to import the structure of another ModelManager, not the runtime structure.

If you already know the IDs of the schemas and definitions, you should use the useDeployedSchema (ModelManager class - Ceramic Developers) and useDeployedDefinition (ModelManager class - Ceramic Developers) methods instead.

1 Like