Dynamoose: [QUESTION] How to extend Document

Created on 29 Nov 2020  路  3Comments  路  Source: dynamoose/dynamoose

Summary:

Under the Model documentation (https://dynamoosejs.com/guide/Model) there is an example where the Document class is extended to achieve type checking.

The example from the docs

// Strongly typed model
class Cat extends Document {
    id: number;
    name: string;
}
const CatModel = dynamoose.model<Cat>("Cat", {"id": Number, "name": String});

This looks like a neat feature, but how do one get a hold of the Document class/type referred to in this example. I can't find anywhere on the dynamoose import where it's exposed?

Thank you.

Other:

  • [x] I have read through the Dynamoose documentation before posting this issue
  • [x] I have searched through the GitHub issues (including closed issues) and pull requests to ensure this question has not already been raised before
  • [x] I have searched the internet and Stack Overflow to ensure this question hasn't been raised or answered before
  • [x] I have filled out all fields above
  • [x] I am running the latest version of Dynamoose
stale question

Most helpful comment

@jornki just import it like that

import { Document } from 'dynamoose/dist/Document';

All 3 comments

@hardyscc Any insight here?

@jornki just import it like that

import { Document } from 'dynamoose/dist/Document';

This issue is stale because it has been open 7 days with no activity. Remove stale label or comment or this will be closed in 3 days.

Was this page helpful?
0 / 5 - 0 ratings