user5304723
user5304723

Reputation:

How to store objectID property in Typescript Interface?

i'm implementing interface and mongoose schemas in Typescript. The struggle with the follow issue:

The Schema should have contain these properties:

let MovementSchema = new Schema
    ({
        movementName : {type: mongoose.Schema.Types.ObjectId, ref: 'MovementName'},
        rounds: [{type: mongoose.Schema.Types.ObjectId, ref: 'Round'}]
    });

the Interface look like this:

import { ObjectId } from "bson";

export interface IMovement {
    movementType : ObjectId,
    rounds : [ ObjectId ]
}

and the question is, the ObjectId is the good type to create properties?

Upvotes: 0

Views: 3410

Answers (1)

user5304723
user5304723

Reputation:

Instead of ObjectId it should be stored as a string.

Upvotes: 4

Related Questions