Skip to content

Commit f2cbbab

Browse files
committed
chore: wip
1 parent ab47542 commit f2cbbab

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

.stacks/core/types/src/model.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export interface TimestampOptions {
1616
*/
1717
export interface Model {
1818
name?: string // defaults to the file name of the model
19-
fields: Field[]
19+
fields: Fields
2020
hasOne?: string
2121
hasMany?: string
2222
belongsToMany?: string
@@ -26,10 +26,11 @@ export interface Model {
2626
// useSoftDeletes?: boolean | SoftDeleteOptions
2727
}
2828

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+
}
3536
}

app/models/User.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
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
44

55
export default <Model> {
66
name: 'User',
7-
searchable: true, // boolean | IndexSettings
7+
searchable: true, // boolean | IndexSettings,
8+
authenticatable: true, // boolean | AuthSettings,
89
seeder: {
910
count: 10,
1011
},
11-
fields: [
12-
{
13-
name: 'name',
12+
fields: {
13+
name: {
1414
validation: validate.string().min(3).max(255),
1515
factory: () => faker.name,
1616
},
17-
{
18-
name: 'email',
17+
email: {
1918
validation: validate.string().min(1).max(255),
2019
unique: true,
2120
factory: () => faker.internet.email,
2221
},
23-
{
24-
name: 'password',
22+
password: {
2523
validation: validate.string().min(6).max(255),
2624
factory: () => faker.internet.password(),
2725
},
28-
],
26+
},
2927
}

functions/api/example.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
// => POST https://localhost:3333/example
12
export {}

0 commit comments

Comments
 (0)