In dynamoose v2:
T extends Document;
model: ModelType<T>;
const attributes: string[] = model.schemas[0].attributes();
In this way I get the attributes names of the schema. How I can get attributes names from model in dynamoose v3?
In dynamoose v3:
T extends Item;
model: ModelType<T>;
const attributes: string[] = model.schemas[0].attributes();
I have the following error: Property 'schemas' does not exist on type 'ModelType<T>'.
I encountered a similar issue while working with Dynamoose 3. Here's a working example how to get model attributes:
If you attempt to create a new record with an undeclared field e.g
surname, Typescript will yell at you.After creating or fetching the model, your IDE will correctly provide you the attributes.
Example 1:
Example 2: