Skip to content

Instantly share code, notes, and snippets.

@shubhamp-sf
Created August 21, 2022 09:24
Show Gist options
  • Save shubhamp-sf/7a5f4c455097d9d9223cb2d3602663fe to your computer and use it in GitHub Desktop.
Save shubhamp-sf/7a5f4c455097d9d9223cb2d3602663fe to your computer and use it in GitHub Desktop.

ENUM Example in Loopback 4 Model

Example file: user.model.ts

enum Role {
  SuperAdmin = 1,
  Admin,
  Subscriber
}

// ...

@property({
  type: 'number',
  jsonSchema: {
    enum: Object.values(Role),
    default: Role.Subscriber,
  },
})
role: Role;

// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment