Skip to content

Commit da5d8ad

Browse files
fix: filtering by enums
1 parent 46c3600 commit da5d8ad

File tree

6 files changed

+179
-149
lines changed

6 files changed

+179
-149
lines changed

example-app/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"license": "MIT",
66
"scripts": {
77
"build": "tsc",
8-
"start": "ts-node src/index.ts",
9-
"start:dev": "concurrently \"yarn build --watch\" \"nodemon --ext '.js' --watch ../build --watch ./build --ignore 'cypress/**/*.js' node build/src/index.js\"",
8+
"start": "node build/src/index.js",
9+
"start:dev": "yarn build && concurrently \"yarn build --watch\" \"nodemon --ext '.js' --watch ../lib --watch ./build --ignore 'cypress/**/*.js' node build/src/index.js\"",
1010
"cypress:open": "cypress open",
1111
"cypress:run": "cypress run"
1212
},
@@ -17,12 +17,12 @@
1717
"cypress": "^4.11.0",
1818
"nodemon": "^2.0.4",
1919
"ts-node": "3.3.0",
20-
"typescript": "3.3.3333"
20+
"typescript": "3.9.7"
2121
},
2222
"dependencies": {
2323
"@admin-bro/core": "^3.0.0-beta.4",
2424
"@admin-bro/express": "^3.0.0-beta.1",
25-
"@admin-bro/typeorm": "^1.0.0",
25+
"@admin-bro/typeorm": "^1.0.1",
2626
"express": "^4.17.1",
2727
"express-formidable": "^1.2.0",
2828
"express-session": "^1.17.1",

example-app/src/entity/User.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm'
1+
import { BaseEntity, Entity, PrimaryGeneratedColumn, Column } from 'typeorm'
2+
3+
export enum UserRoles {
4+
DESIGNER = 'designer',
5+
CLIENT = 'client'
6+
}
27

38
@Entity()
4-
export class User {
9+
export class User extends BaseEntity {
510
@PrimaryGeneratedColumn()
611
id: number;
712

@@ -13,4 +18,10 @@ export class User {
1318

1419
@Column()
1520
age: number;
21+
22+
@Column({
23+
type: 'enum',
24+
enum: UserRoles,
25+
})
26+
public role: UserRoles;
1627
}

example-app/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { createConnection } from 'typeorm'
33
import express from 'express'
44
import AdminBro from '@admin-bro/core'
55
import { buildRouter } from '@admin-bro/express'
6-
import TypeormAdapter from '@admin-bro/typeorm'
6+
import * as TypeormAdapter from '@admin-bro/typeorm'
77
import { User } from './entity/User'
88

99
AdminBro.registerAdapter(TypeormAdapter)
@@ -13,7 +13,9 @@ const PORT = 3000
1313
const run = async () => {
1414
await createConnection()
1515
const app = express()
16-
const admin = new AdminBro()
16+
const admin = new AdminBro({
17+
resources: [User],
18+
})
1719
const router = buildRouter(admin)
1820

1921
app.use(admin.options.rootPath, router)

example-app/tsconfig.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"compilerOptions": {
3+
"baseUrl": ".",
34
"outDir": "./build",
45
"target": "es6",
56
"esModuleInterop": true,
@@ -13,7 +14,12 @@
1314
"types": ["cypress"],
1415
"emitDecoratorMetadata": true,
1516
"experimentalDecorators": true,
16-
"strictPropertyInitialization": false
17+
"strictPropertyInitialization": false,
18+
"sourceMap": true,
19+
"paths": {
20+
"react": ["node_modules/@types/react"],
21+
"@admin-bro/core": ["node_modules/@admin-bro/core"],
22+
}
1723
},
1824
"include": [
1925
"./src/**/*",

0 commit comments

Comments
 (0)