File tree Expand file tree Collapse file tree 3 files changed +19
-19
lines changed Expand file tree Collapse file tree 3 files changed +19
-19
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ export interface TimestampOptions {
16
16
*/
17
17
export interface Model {
18
18
name ?: string // defaults to the file name of the model
19
- fields : Field [ ]
19
+ fields : Fields
20
20
hasOne ?: string
21
21
hasMany ?: string
22
22
belongsToMany ?: string
@@ -26,10 +26,11 @@ export interface Model {
26
26
// useSoftDeletes?: boolean | SoftDeleteOptions
27
27
}
28
28
29
- export interface Field {
30
- name : string
31
- unique ?: boolean
32
- required ?: boolean
33
- factory ?: ( ) => any
34
- validation ?: String | Number | Boolean | Date
29
+ export interface Fields {
30
+ [ key : string ] : {
31
+ unique ?: boolean
32
+ required ?: boolean
33
+ factory ?: ( ) => any
34
+ validation ?: String | Number | Boolean | Date
35
+ }
35
36
}
Original file line number Diff line number Diff line change 1
- import { faker } from 'stacks/core/faker/src'
2
- import { validate } from 'stacks/core/validation'
3
- import type { Model } from 'stacks/core/types/src'
1
+ import { faker } from '../../. stacks/core/faker/src' // stacks/faker or @stacksjs /faker
2
+ import { validate } from '../../. stacks/core/validation/src' // stacks/validate or @stacksjs /validate
3
+ import type { Model } from '../../. stacks/core/types/src' // stacks/types or @stacksjs /types
4
4
5
5
export default < Model > {
6
6
name : 'User' ,
7
- searchable : true , // boolean | IndexSettings
7
+ searchable : true , // boolean | IndexSettings,
8
+ authenticatable : true , // boolean | AuthSettings,
8
9
seeder : {
9
10
count : 10 ,
10
11
} ,
11
- fields : [
12
- {
13
- name : 'name' ,
12
+ fields : {
13
+ name : {
14
14
validation : validate . string ( ) . min ( 3 ) . max ( 255 ) ,
15
15
factory : ( ) => faker . name ,
16
16
} ,
17
- {
18
- name : 'email' ,
17
+ email : {
19
18
validation : validate . string ( ) . min ( 1 ) . max ( 255 ) ,
20
19
unique : true ,
21
20
factory : ( ) => faker . internet . email ,
22
21
} ,
23
- {
24
- name : 'password' ,
22
+ password : {
25
23
validation : validate . string ( ) . min ( 6 ) . max ( 255 ) ,
26
24
factory : ( ) => faker . internet . password ( ) ,
27
25
} ,
28
- ] ,
26
+ } ,
29
27
}
Original file line number Diff line number Diff line change
1
+ // => POST https://localhost:3333/example
1
2
export { }
You can’t perform that action at this time.
0 commit comments