Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ReadonlyArrays in enum prooperty of the SchemaDefinition #10260

Closed
skrtheboss opened this issue May 18, 2021 · 0 comments
Closed

Support ReadonlyArrays in enum prooperty of the SchemaDefinition #10260

skrtheboss opened this issue May 18, 2021 · 0 comments
Labels
typescript Types or Types-test related issue / Pull Request
Milestone

Comments

@skrtheboss
Copy link
Contributor

Do you want to request a feature or report a bug?

Feature

What is the current behavior?
Assigning a readonly array to the enum value is not allowed.

import type { SchemaDefinition, DocumentDefinition } from 'mongoose';

enum Color {
    RED = 'red',
    GREEN = 'green',
    BLUE = 'blue'
}

const colors: ReadonlyArray<Color> = [Color.RED, Color.GREEN, Color.BLUE]; 

interface ColorEntity {
    color: Color;
}

const colorEntitySchemaDefinition: SchemaDefinition<DocumentDefinition<ColorEntity>> = {
    color: {
        type: String,
        enum: colors,
        required: true,
    } 
}

What is the expected behavior?

The SchemaDefinition should allow passing ReadonlyArrays for the enum values.

What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.

node -v
v14.15.5
mongoose -v
v5.12.9
@IslandRhythms IslandRhythms added the new feature This change adds new functionality, like a new method or class label May 18, 2021
@vkarpov15 vkarpov15 added typescript Types or Types-test related issue / Pull Request and removed new feature This change adds new functionality, like a new method or class labels May 19, 2021
@vkarpov15 vkarpov15 added this to the 5.12.11 milestone May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typescript Types or Types-test related issue / Pull Request
Projects
None yet
Development

No branches or pull requests

3 participants