Open bwgjoseph opened 3 years ago
Hi,
Is there any way to grab the ModelMetadata from ModelTypes? Otherwise, is there any existing way to grab it?
ModelMetadata
ModelTypes
My use case is to be able to infer the idKey from the Model
idKey
Model
const modelName = 'posts'; const modelOptions: ModelOptions = { idKey: 'customId', scopeName: 'demopostscope', collectionName: 'demopostcollection', }; const schema = new ottoman.Schema({ text: { type: String, required: true }, }); const postModel = ottoman.getModel(modelName) || ottoman.model(modelName, schema, modelOptions);
I want to do things like
console.log(postModel.getModelMetadata().idKey) // customId console.log(postModel.getModelMetadata().collectionName) // demopostcollection
If there isn't any existing way to do this, is it possible to expose it?
Thanks!
Hi,
Is there any way to grab the
ModelMetadata
fromModelTypes
? Otherwise, is there any existing way to grab it?My use case is to be able to infer the
idKey
from theModel
I want to do things like
If there isn't any existing way to do this, is it possible to expose it?
Thanks!