@@ -7,16 +7,16 @@ Installation: `yarn add @admin-bro/typeorm`
77## Usage
88
99The plugin can be registered using standard ` AdminBro.registerAdapter ` method.
10-
10+ o
1111``` typescript
12- import { Database , Resource } from " @admin-bro/typeorm" ;
12+ import { Database , Resource } from ' @admin-bro/typeorm'
1313import AdminBro from ' admin-bro'
1414
1515AdminBro .registerAdapter ({ Database , Resource });
1616
1717// optional: if you use class-validator you have to inject this to resource.
1818import { validate } from ' class-validator'
19- Resource .validate = validate ;
19+ Resource .validate = validate
2020```
2121
2222## Example
@@ -28,16 +28,16 @@ import {
2828 createConnection ,
2929 ManyToOne ,
3030 RelationId
31- } from ' typeorm' ;
32- import * as express from ' express' ;
33- import { Database , Resource } from ' @admin-bro/typeorm' ;
31+ } from ' typeorm'
32+ import * as express from ' express'
33+ import { Database , Resource } from ' @admin-bro/typeorm'
3434import { validate } from ' class-validator'
3535
36- import AdminBro from ' admin-bro' ;
36+ import AdminBro from ' admin-bro'
3737import * as AdminBroExpress from ' @admin-bro/express'
3838
39- Resource .validate = validate ;
40- AdminBro .registerAdapter ({ Database , Resource });
39+ Resource .validate = validate
40+ AdminBro .registerAdapter ({ Database , Resource })
4141
4242@Entity ()
4343export class Person extends BaseEntity
@@ -67,26 +67,86 @@ export class Person extends BaseEntity
6767
6868( async () =>
6969{
70- const connection = await createConnection ({/* ... */ });
70+ const connection = await createConnection ({/* ... */ })
7171
7272 // Applying connection to model
73- Person .useConnection (connection );
73+ Person .useConnection (connection )
7474
7575 const adminBro = new AdminBro ({
7676 // databases: [connection],
7777 resources: [
7878 { resource: Person , options: { parent: { name: ' foobar' } } }
7979 ],
8080 rootPath: ' /admin' ,
81- });
81+ })
8282
83- const app = express ();
84- const router = AdminBroExpress .buildRouter (adminBro );
85- app .use (adminBro .options .rootPath , router );
86- app .listen (3000 );
87- })();
83+ const app = express ()
84+ const router = AdminBroExpress .buildRouter (adminBro )
85+ app .use (adminBro .options .rootPath , router )
86+ app .listen (3000 )
87+ })()
8888```
8989
9090## ManyToOne
9191
9292Admin supports ManyToOne relationship but you also have to define @RealationId as stated in the example above.
93+
94+ ## Contribution
95+
96+ ### Running the example app
97+
98+ If you want to set this up locally this is the suggested process:
99+
100+ 1 . fork the repo
101+ 2 . Install dependencies
102+
103+ ```
104+ yarn install
105+ ```
106+
107+ 3 . register this package as a (linked package)[ https://classic.yarnpkg.com/en/docs/cli/link/ ]
108+
109+ ```
110+ yarn link
111+ ```
112+
113+ 4 . Setup example app
114+
115+ Install all dependencies and use previously linked version of ` @admin-bro/typeorm ` .
116+
117+ ```
118+ cd example-app
119+ yarn install
120+ yarn link @admin-bro/typeorm
121+ ```
122+
123+ Optionally you might want to link your local version of ` admin-bro ` package
124+
125+ 5 . Make sure you have all the envs set (which are defined in ` example-app/ormconfig.js ` )
126+
127+ 6 . Build the package in watch mode
128+
129+ (in the root folder)
130+
131+ ```
132+ yarn watch
133+ ```
134+
135+ 6 . run the app in the dev mode
136+
137+ ```
138+ cd example-app
139+ yarn start:dev
140+ ```
141+
142+ ### Pull request
143+
144+ Before you make a PR make sure all tests pass and your code wont causes linter errors.
145+ You can do this by running:
146+
147+ ```
148+ yarn lint
149+ yarn test
150+ ```
151+
152+ or with proper envs: ` POSTGRES_USER=yourtestuser POSTGRES_DATABASE="database_test" yarn test `
0 commit comments